-
Notifications
You must be signed in to change notification settings - Fork 109
feat:locations.geojson
file parsing and geometry validation
#1879
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
00f6437
feat: GeoJSON geometry validation
cka-y 06be75e
Merge branch 'master' into feat/validate-polygons
cka-y a25b7c3
merge: master
cka-y b9421d1
fix: added notices + pr comments
cka-y 4a14710
Merge branch 'master' into feat/validate-polygons
cka-y e91e246
fix: PR comments
cka-y e8e473d
Merge branch 'master' into feat/validate-polygons
cka-y 50bacff
Merge branch 'master' into feat/validate-polygons
cka-y 8c0211d
Update main/src/main/java/org/mobilitydata/gtfsvalidator/table/GeoJso…
cka-y 253de25
Update main/src/main/java/org/mobilitydata/gtfsvalidator/table/GeoJso…
cka-y 3f1fd7b
Merge branch 'master' into feat/validate-polygons
cka-y 7409af7
fix: lint
cka-y 35eca02
fix: added feature index to InvalidGeometryNotice
cka-y d5c19c4
Merge branch 'master' into feat/validate-polygons
cka-y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
core/src/main/java/org/mobilitydata/gtfsvalidator/notice/InvalidGeometryNotice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2024 MobilityData LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mobilitydata.gtfsvalidator.notice; | ||
|
||
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR; | ||
|
||
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice; | ||
|
||
/** | ||
* A polygon in `locations.geojson` is unparsable or invalid. | ||
* | ||
* <p>Each polygon must be valid by the definition of the <a | ||
* href="http://www.opengis.net/doc/is/sfa/1.2.1" target="_blank"> OpenGIS Simple Features | ||
* Specification, section 6.1.11 </a>. | ||
*/ | ||
@GtfsValidationNotice(severity = ERROR) | ||
public class InvalidGeometryNotice extends ValidationNotice { | ||
|
||
/** The id of the faulty record. */ | ||
private final String featureId; | ||
|
||
/** The geometry type of the feature containing the invalid polygon. */ | ||
private final String geometryType; | ||
|
||
/** The validation error details. */ | ||
private final String message; | ||
|
||
public InvalidGeometryNotice(String featureId, String geometryType, String validationError) { | ||
this.featureId = featureId; | ||
this.geometryType = geometryType; | ||
this.message = validationError; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
core/src/main/java/org/mobilitydata/gtfsvalidator/notice/MalformedJsonNotice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 MobilityData LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mobilitydata.gtfsvalidator.notice; | ||
|
||
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR; | ||
|
||
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice; | ||
|
||
/** A JSON file is malformed. */ | ||
@GtfsValidationNotice(severity = ERROR) | ||
public class MalformedJsonNotice extends ValidationNotice { | ||
|
||
/** The name of the faulty file. */ | ||
private final String filename; | ||
|
||
public MalformedJsonNotice(String filename) { | ||
this.filename = filename; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
core/src/main/java/org/mobilitydata/gtfsvalidator/notice/MissingRequiredElementNotice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2024 MobilityData LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mobilitydata.gtfsvalidator.notice; | ||
|
||
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR; | ||
|
||
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice; | ||
|
||
/** A required element is missing in `locations.geojson`. */ | ||
@GtfsValidationNotice(severity = ERROR) | ||
public class MissingRequiredElementNotice extends ValidationNotice { | ||
/** Index of the feature in the feature collection. */ | ||
private final Integer featureIndex; | ||
|
||
/** The id of the faulty record. */ | ||
private final String featureId; | ||
|
||
/** The missing required element. */ | ||
private final String missingElement; | ||
|
||
public MissingRequiredElementNotice( | ||
String featureId, String missingElement, Integer featureIndex) { | ||
this.featureId = featureId; | ||
this.featureIndex = featureIndex; | ||
this.missingElement = missingElement; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
core/src/main/java/org/mobilitydata/gtfsvalidator/notice/UnsupportedFeatureTypeNotice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2024 MobilityData LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mobilitydata.gtfsvalidator.notice; | ||
|
||
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR; | ||
|
||
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice; | ||
|
||
/** | ||
* An unsupported feature type is used in the `locations.geojson` file. | ||
* | ||
* <p>Use `Feature` instead to comply with the spec. | ||
*/ | ||
@GtfsValidationNotice(severity = ERROR) | ||
public class UnsupportedFeatureTypeNotice extends ValidationNotice { | ||
|
||
/** The value of the unsupported GeoJSON type. */ | ||
Integer featureIndex; | ||
|
||
/** The id of the faulty record. */ | ||
String featureId; | ||
|
||
/** The feature type of the faulty record. */ | ||
String featureType; | ||
|
||
public UnsupportedFeatureTypeNotice(Integer featureIndex, String featureId, String featureType) { | ||
this.featureIndex = featureIndex; | ||
this.featureId = featureId; | ||
this.featureType = featureType; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
core/src/main/java/org/mobilitydata/gtfsvalidator/notice/UnsupportedGeoJsonTypeNotice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2024 MobilityData LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mobilitydata.gtfsvalidator.notice; | ||
|
||
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR; | ||
|
||
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice; | ||
|
||
/** | ||
* An unsupported GeoJSON type is used in the `locations.geojson` file. | ||
* | ||
* <p>Use `FeatureCollection` instead to comply with the spec. | ||
*/ | ||
@GtfsValidationNotice(severity = ERROR) | ||
public class UnsupportedGeoJsonTypeNotice extends ValidationNotice { | ||
|
||
/** The value of the unsupported GeoJSON type. */ | ||
private final String geoJsonType; | ||
|
||
public UnsupportedGeoJsonTypeNotice(String geoJsonType) { | ||
this.geoJsonType = geoJsonType; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
core/src/main/java/org/mobilitydata/gtfsvalidator/notice/UnsupportedGeometryTypeNotice.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2024 MobilityData LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.mobilitydata.gtfsvalidator.notice; | ||
|
||
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR; | ||
|
||
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice; | ||
|
||
/** | ||
* A GeoJSON feature has an unsupported geometry type in `locations.geojson`. | ||
* | ||
* <p>Each feature must have a geometry type that is supported by the GTFS spec. The supported | ||
* geometry types `Polygon` and `MultiPolygon`. | ||
*/ | ||
@GtfsValidationNotice(severity = ERROR) | ||
public class UnsupportedGeometryTypeNotice extends ValidationNotice { | ||
|
||
/** The index of the feature in the feature collection. */ | ||
private final int featureIndex; | ||
|
||
/** The id of the faulty record. */ | ||
private final String featureId; | ||
|
||
/** The geometry type of the faulty record. */ | ||
private final String geometryType; | ||
|
||
public UnsupportedGeometryTypeNotice(int featureIndex, String featureId, String geometryType) { | ||
this.featureIndex = featureIndex; | ||
this.featureId = featureId; | ||
this.geometryType = geometryType; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.