Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- implicit class RichString(val s: String) extends AnyVal {
- def parseGeoJson[T: JsonReader] = s.parseJson.convertTo[T]
- def extractFeatures[T: JsonReader] = s.parseJson.convertTo[T]
- def extractGeometries[G <: Geometry] = {
- val geoms = s.parseJson.convertTo[G]
- geoms match {
- case _:Geometry => geoms
- case _ => Seq[G]()
- }
- }
- }
- /*
- val json: String = ???
- val p = json.extractGeometries[G <: Geometry]: Seq[G] // May be empty
- val p = json.extractFeatures[G <: Geometry, D]: Seq[Feature[G, D]]
- val p = json.parseGeoJson[PolygonFeature[Int]]: PolygonFeature[Int] // This expects all the types to line up, throws if not.
- val p = json.parseGeojson[JsonFeatureCollection].getAllPolygonFeature[D]().head
- p
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement