Skip to content

Commit 8ae8498

Browse files
committed
fix(GisExportJob): fix projection for stops and routes export
fixes #203
1 parent aaf1575 commit 8ae8498

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/com/conveyal/datatools/manager/jobs/GisExportJob.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ public GisExportJob(ExportType exportType, File file, Collection<String> feedIds
7878
ShapefileDataStore datastore = (ShapefileDataStore) dataStoreFactory.createNewDataStore(params);
7979
datastore.forceSchemaCRS(DefaultGeographicCRS.WGS84);
8080

81-
final SimpleFeatureType STOP_TYPE = // createStopFeatureType();
82-
DataUtilities.createType(
81+
final SimpleFeatureType STOP_TYPE = DataUtilities.createType(
8382
"Stop",
8483
String.join(",",
8584
// Geometry must be the first attribute for a shapefile (and must be named
86-
// "the_geom").
87-
"the_geom:Point",
85+
// "the_geom"). We must include SRID, otherwise the projection will be undefined.
86+
"the_geom:Point:srid=4326",
8887
"name:String",
8988
"code:String",
9089
"desc:String",
@@ -96,6 +95,8 @@ public GisExportJob(ExportType exportType, File file, Collection<String> feedIds
9695
final SimpleFeatureType ROUTE_TYPE = DataUtilities.createType(
9796
"Route", // <- the name for our feature type
9897
String.join(",",
98+
// Geometry must be the first attribute for a shapefile (and must be named
99+
// "the_geom"). We must include SRID, otherwise the projection will be undefined.
99100
"the_geom:LineString:srid=4326",
100101
"pattName:String",
101102
"shortName:String",
@@ -158,7 +159,9 @@ public GisExportJob(ExportType exportType, File file, Collection<String> feedIds
158159
// exporting a shapefile. If there are future similar cases, we may need to
159160
// refactor this into a more structured operation using Java objects or
160161
// com.conveyal.gtfs.loader.Feed
161-
String patternsSql = Table.PATTERNS.generateSelectSql(version.namespace, Requirement.EDITOR);
162+
// Note: we use generateSelectAllSql because we encountered an issue with some feeds (perhaps legacy)
163+
// not containing the column patterns#direction_id. See https://github.com/ibi-group/datatools-server/issues/203
164+
String patternsSql = Table.PATTERNS.generateSelectAllSql(version.namespace);
162165
PreparedStatement statement = connection.prepareStatement(patternsSql);
163166
ResultSet resultSet = statement.executeQuery();
164167
// we loop over trip patterns. Note that this will yield several lines for routes that have

src/test/java/com/conveyal/datatools/manager/jobs/GisExportJobTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.geotools.data.DataStore;
1414
import org.geotools.data.DataStoreFinder;
1515
import org.geotools.data.FeatureSource;
16+
import org.geotools.data.shapefile.ShapefileDataStore;
1617
import org.geotools.feature.FeatureCollection;
1718
import org.geotools.feature.FeatureIterator;
1819
import org.junit.BeforeClass;

0 commit comments

Comments
 (0)