Skip to content

Commit

Permalink
fix: added notices + pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cka-y committed Oct 9, 2024
1 parent a25b7c3 commit b9421d1
Show file tree
Hide file tree
Showing 21 changed files with 277 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
*/
package org.mobilitydata.gtfsvalidator.notice;

import static org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRef.TERM_DEFINITIONS;
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR;

import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRefs;

/**
* A polygon in `locations.geojson` is unparsable or invalid.
Expand All @@ -28,7 +26,7 @@
* 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, sections = @SectionRefs(TERM_DEFINITIONS))
@GtfsValidationNotice(severity = ERROR)
public class InvalidGeometryNotice extends ValidationNotice {

/** The id of the faulty record. */
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@
*/
package org.mobilitydata.gtfsvalidator.notice;

import static org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRef.TERM_DEFINITIONS;
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR;

import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRefs;

/** A required element is missing in `locations.geojson`. */
@GtfsValidationNotice(severity = ERROR, sections = @SectionRefs(TERM_DEFINITIONS))
@GtfsValidationNotice(severity = ERROR)
public class MissingRequiredElementNotice extends ValidationNotice {
/** Index of the feature in the feature collection. */
private final int featureIndex;
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, int featureIndex) {
public MissingRequiredElementNotice(
String featureId, String missingElement, Integer featureIndex) {
this.featureId = featureId;
this.featureIndex = featureIndex;
this.missingElement = missingElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@
*/
package org.mobilitydata.gtfsvalidator.notice;

import static org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRef.TERM_DEFINITIONS;
import static org.mobilitydata.gtfsvalidator.notice.SeverityLevel.ERROR;

import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice;
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidationNotice.SectionRefs;

/**
* 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, sections = @SectionRefs(TERM_DEFINITIONS))
@GtfsValidationNotice(severity = ERROR)
public class UnsupportedGeometryTypeNotice extends ValidationNotice {

/** The index of the feature in the feature collection. */
Expand Down
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 location type is used in the `locations.geojson` file.
*
* <p>The supported type is `FeatureCollection`.
*/
@GtfsValidationNotice(severity = ERROR)
public class UnsupportedLocationTypeNotice extends ValidationNotice {

/** The value of the unsupported location type. */
private final String locationTypeValue;

public UnsupportedLocationTypeNotice(String locationTypeValue) {
this.locationTypeValue = locationTypeValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* This class is the parent of containers holding table (csv) entities and containers holding JSON
* entities
*
* @param <T> The entity for this container (e.g. GtfsCalendarDate or GtfsGeoJSONFeature )
* @param <T> The entity for this container (e.g. GtfsCalendarDate or GtfsGeoJsonFeature )
* @param <D> The descriptor for the file for the container (e.g. GtfsCalendarDateTableDescriptor or
* GtfsGeoJSONFileDescriptor)
* GtfsGeoJsonFileDescriptor)
*/
public abstract class GtfsEntityContainer<T extends GtfsEntity, D extends GtfsFileDescriptor> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* relate to either a csv table or a GeoJSON file.
*
* @param <T> The entity that will be extracted from the file. For example, GtfsCalendarDate or
* GtfsGeoJSONFeature
* GtfsGeoJsonFeature
*/
public abstract class GtfsFileDescriptor<T extends GtfsEntity> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,16 +605,11 @@ public ImmutableSortedSet<String> getFilenames() {
}

public Boolean hasFlexFeatures() {
try {
return specFeatures.keySet().stream()
.anyMatch(
feature ->
feature.getFeatureGroup() != null
&& feature.getFeatureGroup().equals("Flexible Services")
&& specFeatures.get(feature));

} catch (Exception e) {
return false;
}
return specFeatures.keySet().stream()
.anyMatch(
feature ->
feature.getFeatureGroup() != null
&& feature.getFeatureGroup().equals("Flexible Services")
&& specFeatures.get(feature));
}
}
Loading

0 comments on commit b9421d1

Please sign in to comment.