Hi all,

I'm new to the list, so please forgive (and advise of) any transgressions
or failures of etiquette.

I'm trying to read GeoJSON into an STRtree for querying. I‘ve managed to
create STRtrees from ESRI Shapefiles, but I’m having a lot of trouble
making it work with the GeoJSON. I always get a NullPointerException every
time I try to get the internal envelope for the MultiPolygons in the file.

I'm working in Scala, and the relevant psuedocode looks something like:

def readGeoJSONtoRtree(gjson: String): STRtree = {
  val index = new STRtree
  val file = new File(gjson)

  val features = (new FeatureJSON).streamFeatureCollection(file)
try {
  while(features.hasNext) {
    val feature = features.next
    val geom   = feature.getDefaultGeometry.asInstanceOf[MultiPolygon]
    val envelope = geom.getEnvelopeInternal

     index.insert(envelope, feature)
  }

} finally {
   features.close
}

index

}

When I run this, I get a NullPointerException and as I‘ve tried to debug,
it’s looked like the geometry of the MultiPolygon object in the GeoJSON is
not being read correctly. Am I doing something totally wrong here? Or is
there maybe a better way to accomplish this task?

Thanks,
Kiran
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to