Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onebusaway-gtfs throws an error when locations.geojson has unknown fields #188

Open
optionsome opened this issue Apr 4, 2022 · 0 comments

Comments

@optionsome
Copy link

Summary:

The onebusaway-gtfs library throws an error while processing locations.geojson if it has unhandled fields.

Steps to reproduce:

Modify some GTFS-flex data set to contain locations.geojson with extra fields such as style. I ran into this problem while using the onebusaway-gtfs library through OpenTripPlanner (version 2.x).

Expected behavior:

The GTFS-flex specification says "This file uses a subset of the GeoJSON format, described in RFC 7946." but we don't necessarily have to disallow extra fields. For other .txt (csv) format gtfs files, we just ignore the fields that we don't handle. Therefore, as it might make sense to use some extra fields in the data for other context (such as visualizing the data), we should probably just ignore the extra fields instead of being overly strict.

@leonardehrenfried already pointed out in the MobilityData gtfs-flex slack channel that the issue is probably due to jackson's default behaviour that can be changed to ignore unknown fields https://attacomsian.com/blog/jackson-ignore-unknown-json-properties

Observed behavior:

There was an error while processing the data:

14:46:54.559 ERROR (OTPMain.java:59) An uncaught error occurred inside OTP: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "style" (class org.geojson.Feature), not marked as ignorable (5 known properties: "bbox", "geometry", "properties", "crs", "id"])
 at [Source: (InputStreamReader); line: 1, column: 94272] (through reference chain: org.geojson.FeatureCollection["features"]->java.util.ArrayList[0]->org.geojson.Feature["style"])
java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "style" (class org.geojson.Feature), not marked as ignorable (5 known properties: "bbox", "geometry", "properties", "crs", "id"])
 at [Source: (InputStreamReader); line: 1, column: 94272] (through reference chain: org.geojson.FeatureCollection["features"]->java.util.ArrayList[0]->org.geojson.Feature["style"])
	at org.opentripplanner.graph_builder.module.GtfsModule.buildGraph(GtfsModule.java:143)
	at org.opentripplanner.graph_builder.GraphBuilder.run(GraphBuilder.java:83)
	at org.opentripplanner.standalone.OTPMain.startOTPServer(OTPMain.java:136)
	at org.opentripplanner.standalone.OTPMain.main(OTPMain.java:52)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "style" (class org.geojson.Feature), not marked as ignorable (5 known properties: "bbox", "geometry", "properties", "crs", "id"])
 at [Source: (InputStreamReader); line: 1, column: 94272] (through reference chain: org.geojson.FeatureCollection["features"]->java.util.ArrayList[0]->org.geojson.Feature["style"])
	at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:61)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:1127)
	at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1989)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1700)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1678)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:319)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:214)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:186)
	at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:144)
	at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:110)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1292)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:357)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
	at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:313)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:214)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:186)
	at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:144)
	at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:110)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1292)
	at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:74)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3642)
	at org.onebusaway.gtfs.serialization.LocationsGeoJSONReader.read(LocationsGeoJSONReader.java:41)
	at org.onebusaway.gtfs.serialization.GtfsReader.readEntities(GtfsReader.java:166)
	at org.onebusaway.csv_entities.CsvEntityReader.readEntities(CsvEntityReader.java:120)
	at org.onebusaway.csv_entities.CsvEntityReader.readEntities(CsvEntityReader.java:115)
	at org.onebusaway.csv_entities.CsvEntityReader.readEntities(CsvEntityReader.java:108)
	at org.opentripplanner.graph_builder.module.GtfsModule.loadBundle(GtfsModule.java:224)
	at org.opentripplanner.graph_builder.module.GtfsModule.buildGraph(GtfsModule.java:111)
	... 3 common frames omitted

Platform:

What is the operating system and Java version of your machine? What version of the onebusaway-gtfs-modules did you use?
Java 17 and 1.3.103 version of onebusaway-gtfs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant