1515
1616import mil .nga .giat .geowave .adapter .vector .FeatureDataAdapter ;
1717import mil .nga .giat .geowave .adapter .vector .ingest .AbstractSimpleFeatureIngestPlugin ;
18- import mil .nga .giat .geowave .core . geotime .GeometryUtils ;
18+ import mil .nga .giat .geowave .adapter . vector . utils .GeometryUtils ;
1919import mil .nga .giat .geowave .core .geotime .IndexType ;
2020import mil .nga .giat .geowave .core .index .ByteArrayId ;
2121import mil .nga .giat .geowave .core .index .StringUtils ;
3434import org .apache .commons .io .IOUtils ;
3535import org .apache .log4j .Logger ;
3636import org .geotools .feature .simple .SimpleFeatureBuilder ;
37+ import org .geotools .referencing .CRS ;
3738import org .opengis .feature .simple .SimpleFeature ;
3839import org .opengis .feature .simple .SimpleFeatureType ;
40+ import org .opengis .referencing .FactoryException ;
41+ import org .opengis .referencing .crs .CoordinateReferenceSystem ;
3942
4043import com .vividsolutions .jts .geom .Coordinate ;
44+ import com .vividsolutions .jts .geom .GeometryFactory ;
4145
4246/*
4347 */
@@ -58,6 +62,8 @@ public class GeoLifeIngestPlugin extends
5862
5963 private final Index [] supportedIndices ;
6064
65+ private CoordinateReferenceSystem crs ;
66+
6167 public GeoLifeIngestPlugin () {
6268 geolifePointType = GeoLifeUtils .createGeoLifePointDataType ();
6369 pointKey = new ByteArrayId (
@@ -75,7 +81,14 @@ public GeoLifeIngestPlugin() {
7581 IndexType .SPATIAL_VECTOR .createDefaultIndex (),
7682 IndexType .SPATIAL_TEMPORAL_VECTOR .createDefaultIndex ()
7783 };
78-
84+ try {
85+ crs = CRS .decode ("EPSG:4326" );
86+ }
87+ catch (FactoryException e ) {
88+ LOGGER .error (
89+ "Unable to decode Coordinate Reference System authority code!" ,
90+ e );
91+ }
7992 }
8093
8194 @ Override
@@ -183,6 +196,9 @@ protected CloseableIterator<GeoWaveData<SimpleFeature>> toGeoWaveDataInternal(
183196 Date startTimeStamp = null ;
184197 Date endTimeStamp = null ;
185198 String timestring = "" ;
199+ GeometryFactory geometryFactory = new GeometryFactory ();
200+ double currLat ;
201+ double currLng ;
186202 try {
187203 while ((line = br .readLine ()) != null ) {
188204
@@ -191,13 +207,21 @@ protected CloseableIterator<GeoWaveData<SimpleFeature>> toGeoWaveDataInternal(
191207 continue ;
192208 }
193209
194- final Coordinate cord = new Coordinate (
210+ currLat = GeometryUtils .adjustCoordinateDimensionToRange (
211+ Double .parseDouble (vals [0 ]),
212+ crs ,
213+ 1 );
214+ currLng = GeometryUtils .adjustCoordinateDimensionToRange (
195215 Double .parseDouble (vals [1 ]),
196- Double .parseDouble (vals [0 ]));
216+ crs ,
217+ 0 );
218+ final Coordinate cord = new Coordinate (
219+ currLng ,
220+ currLat );
197221 pts .add (cord );
198222 geolifePointBuilder .set (
199223 "geometry" ,
200- GeometryUtils . GEOMETRY_FACTORY .createPoint (cord ));
224+ geometryFactory .createPoint (cord ));
201225 geolifePointBuilder .set (
202226 "trackid" ,
203227 trackId );
@@ -218,10 +242,10 @@ protected CloseableIterator<GeoWaveData<SimpleFeature>> toGeoWaveDataInternal(
218242
219243 geolifePointBuilder .set (
220244 "Latitude" ,
221- Double . parseDouble ( vals [ 0 ]) );
245+ currLat );
222246 geolifePointBuilder .set (
223247 "Longitude" ,
224- Double . parseDouble ( vals [ 1 ]) );
248+ currLng );
225249
226250 Double elevation = Double .parseDouble (vals [3 ]);
227251 if (elevation == -777 ) {
@@ -238,7 +262,7 @@ protected CloseableIterator<GeoWaveData<SimpleFeature>> toGeoWaveDataInternal(
238262
239263 geolifeTrackBuilder .set (
240264 "geometry" ,
241- GeometryUtils . GEOMETRY_FACTORY .createLineString (pts .toArray (new Coordinate [pts .size ()])));
265+ geometryFactory .createLineString (pts .toArray (new Coordinate [pts .size ()])));
242266
243267 geolifeTrackBuilder .set (
244268 "StartTimeStamp" ,
0 commit comments