Какой импорт необходим, чтобы найти неявные доказательства для компиляции вызова GeoJson.parse из GeoTrellis?
geotrellis.vector.io.json.Geometry использует spray.json для анализа и должен иметь возможность находить экземпляр JsonReader или JsonFormats, настроенный на классы WithCrs и Geometry.
Доказательством являетсяопределены в FeatureFormats;но как может использовать приведенный ниже фрагмент кода?
Следующее не разрешает доказательства:
- Импорт всего в пакете
geotrellis.vector.io.json.*
- Импорт Implicits специально
import geotrellis.vector.io.json.Implicits
- Импортировать форматы объектов напрямую
import geotrellis.vector.io.json.FeatureFormats
- Обеспечить правильный импорт, особенно отсутствие импорта
com.vividsolutions.jts.Geometry
, который бы маскировал целевой объект
Вотрассматриваемый код
import geotrellis.vector.Geometry
import geotrellis.proj4.CRS
import geotrellis.vector.io.json.*
import geotrellis.vector.io.json.{GeoJson, WithCrs}
import org.json4s.{DefaultFormats, Formats}
import scala.util.{Failure, Success, Try}
val exampleQueryJson =
"""
|{
| "type": "Polygon",
| "crs": {
| "type": "name",
| "properties": {
| "name": "EPSG:4326"
| }
| },
| "coordinates": [
| [
| [....]
| ]
| ]
|}
""".stripMargin
class GeometryReader extends FeatureFormats {
implicit val jsonFormats: Formats = DefaultFormats
}
object GeometryReader {
def parseGeometry(request: String): Geometry = {
GeoJson.parse[Geometry](request)
}
}
val g = GeometryReader.parseGeometry(exampleQueryJson)
Ошибка компиляции показывает невозможность найти правильное доказательство с учетом того, что в данный момент доступно
[error] /path/redacted/GeometryReader.scala:19: Cannot find JsonReader or JsonFormat type class for geotrellis.vector.io.json.WithCrs[geotrellis.vector.Geometry]
[error] val geometryWithCrs: WithCrs[Geometry] = GeoJson.parse[WithCrs[Geometry]](request)
[error] ^
[error] /path/redacted/GeometryReader.scala:25: Cannot find JsonReader or JsonFormat type class for geotrellis.vector.Geometry
[error] Try(GeoJson.parse[Geometry](request)) match {
[error] ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed