Skip to content

Commit

Permalink
GEOMESA-3288 Fix ingest for shapefiles with EPSG:4326
Browse files Browse the repository at this point in the history
  • Loading branch information
elahrvivaz committed Jul 27, 2023
1 parent f9ed222 commit 56e0cfa
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.codahale.metrics.Counter
import com.typesafe.scalalogging.LazyLogging
import org.geotools.data.shapefile.{ShapefileDataStore, ShapefileDataStoreFactory}
import org.geotools.data.{DataStoreFinder, Query}
import org.geotools.referencing.CRS
import org.locationtech.geomesa.convert.EvaluationContext
import org.locationtech.geomesa.convert2.AbstractConverter
import org.locationtech.geomesa.convert2.AbstractConverter.{BasicConfig, BasicField, BasicOptions}
Expand Down Expand Up @@ -64,11 +65,11 @@ class ShapefileConverter(sft: SimpleFeatureType, config: BasicConfig, fields: Se
}

val q = new Query
// Only ask to reproject if the Shapefile has a CRS
if (ds.getSchema.getCoordinateReferenceSystem != null) {
q.setCoordinateSystemReproject(CRS_EPSG_4326)
} else {
// Only ask to reproject if the Shapefile has a non-4326 CRS
if (ds.getSchema.getCoordinateReferenceSystem == null) {
logger.warn(s"Shapefile does not have CRS info")
} else if (!CRS.equalsIgnoreMetadata(ds.getSchema.getCoordinateReferenceSystem, CRS_EPSG_4326)) {
q.setCoordinateSystemReproject(CRS_EPSG_4326)
}

val reader = CloseableIterator(ds.getFeatureSource.getReader(q)).map { f => ec.line += 1; f }
Expand Down

0 comments on commit 56e0cfa

Please sign in to comment.