From 56e0cfa72dfbe7ac7f6312b983843d04222c10c0 Mon Sep 17 00:00:00 2001 From: Emilio Lahr-Vivaz Date: Thu, 27 Jul 2023 14:26:06 +0000 Subject: [PATCH] GEOMESA-3288 Fix ingest for shapefiles with EPSG:4326 --- .../geomesa/convert/shp/ShapefileConverter.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/geomesa-convert/geomesa-convert-shp/src/main/scala/org/locationtech/geomesa/convert/shp/ShapefileConverter.scala b/geomesa-convert/geomesa-convert-shp/src/main/scala/org/locationtech/geomesa/convert/shp/ShapefileConverter.scala index 7d59137bc605..dc4fb0ead15a 100644 --- a/geomesa-convert/geomesa-convert-shp/src/main/scala/org/locationtech/geomesa/convert/shp/ShapefileConverter.scala +++ b/geomesa-convert/geomesa-convert-shp/src/main/scala/org/locationtech/geomesa/convert/shp/ShapefileConverter.scala @@ -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} @@ -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 }