Search in sources :

Example 1 with ShiftNegativeStopTimesUpdateStrategy

use of org.onebusaway.gtfs_transformer.updates.ShiftNegativeStopTimesUpdateStrategy in project onebusaway-gtfs-modules by OneBusAway.

the class TransformFactory method addModificationsFromReader.

public void addModificationsFromReader(BufferedReader reader) throws IOException, TransformSpecificationException {
    String line = null;
    while ((line = reader.readLine()) != null) {
        try {
            line = line.trim();
            if (line.length() == 0 || line.startsWith("#") || line.equals("{{{") || line.equals("}}}"))
                continue;
            JSONObject json = new JSONObject(line);
            if (!json.has(ARG_OP)) {
                throw new TransformSpecificationMissingArgumentException(line, ARG_OP);
            }
            String opType = json.getString(ARG_OP);
            if (opType.equals("add")) {
                handleAddOperation(line, json);
            } else if (opType.equals(ARG_UPDATE) || opType.equals("change") || opType.equals("modify")) {
                handleUpdateOperation(line, json);
            } else if (opType.equals("remove") || opType.equals("delete")) {
                handleRemoveOperation(line, json);
            } else if (opType.equals("retain")) {
                handleRetainOperation(line, json);
            } else if (opType.equals("subsection")) {
                handleSubsectionOperation(line, json);
            } else if (opType.equals("trim_trip")) {
                handleTrimOperation(line, json);
            } else if (opType.equals("stop_times_factory")) {
                handleStopTimesOperation(line, json);
            } else if (opType.equals("calendar_extension")) {
                handleTransformOperation(line, json, new CalendarExtensionStrategy());
            } else if (opType.equals("calendar_simplification")) {
                handleTransformOperation(line, json, new CalendarSimplicationStrategy());
            } else if (opType.equals("deduplicate_service_ids")) {
                handleTransformOperation(line, json, new DeduplicateServiceIdsStrategy());
            } else if (opType.equals("shift_negative_stop_times")) {
                handleTransformOperation(line, json, new ShiftNegativeStopTimesUpdateStrategy());
            } else if (opType.equals("shape_direction")) {
                handleTransformOperation(line, json, new ShapeDirectionTransformStrategy());
            } else if (opType.equals("transform")) {
                handleTransformOperation(line, json);
            } else {
                throw new TransformSpecificationException("unknown transform op \"" + opType + "\"", line);
            }
        } catch (JSONException ex) {
            throw new TransformSpecificationException("error parsing json", ex, line);
        }
    }
}
Also used : ShiftNegativeStopTimesUpdateStrategy(org.onebusaway.gtfs_transformer.updates.ShiftNegativeStopTimesUpdateStrategy) JSONObject(org.json.JSONObject) CalendarSimplicationStrategy(org.onebusaway.gtfs_transformer.updates.CalendarSimplicationStrategy) ShapeDirectionTransformStrategy(org.onebusaway.gtfs_transformer.updates.ShapeDirectionTransformStrategy) JSONException(org.json.JSONException) TransformSpecificationMissingArgumentException(org.onebusaway.gtfs_transformer.TransformSpecificationMissingArgumentException) DeduplicateServiceIdsStrategy(org.onebusaway.gtfs_transformer.updates.DeduplicateServiceIdsStrategy) CalendarExtensionStrategy(org.onebusaway.gtfs_transformer.updates.CalendarExtensionStrategy) TransformSpecificationException(org.onebusaway.gtfs_transformer.TransformSpecificationException)

Aggregations

JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 TransformSpecificationException (org.onebusaway.gtfs_transformer.TransformSpecificationException)1 TransformSpecificationMissingArgumentException (org.onebusaway.gtfs_transformer.TransformSpecificationMissingArgumentException)1 CalendarExtensionStrategy (org.onebusaway.gtfs_transformer.updates.CalendarExtensionStrategy)1 CalendarSimplicationStrategy (org.onebusaway.gtfs_transformer.updates.CalendarSimplicationStrategy)1 DeduplicateServiceIdsStrategy (org.onebusaway.gtfs_transformer.updates.DeduplicateServiceIdsStrategy)1 ShapeDirectionTransformStrategy (org.onebusaway.gtfs_transformer.updates.ShapeDirectionTransformStrategy)1 ShiftNegativeStopTimesUpdateStrategy (org.onebusaway.gtfs_transformer.updates.ShiftNegativeStopTimesUpdateStrategy)1