diff --git a/.github/workflows/close_stale_pr_and_issues.yml b/.github/workflows/close_stale_pr_and_issues.yml new file mode 100644 index 00000000000..726852c24d8 --- /dev/null +++ b/.github/workflows/close_stale_pr_and_issues.yml @@ -0,0 +1,23 @@ +name: 'Close Stale issues' + +on: + schedule: + - cron: '30 7 * * *' + workflow_dispatch: + +permissions: + issues: write + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v5.0.0 + id: stale + with: + stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days' + days-before-stale: 90 + days-before-close: 30 + operations-per-run: 6 + exempt-issue-labels: 'Roadmap' + ascending: true diff --git a/pom.xml b/pom.xml index a25eaedc8cb..a3eb6fb8371 100644 --- a/pom.xml +++ b/pom.xml @@ -85,53 +85,6 @@ src/ext-test/resources - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - [1.0,) - - copy-dependencies - - - - - - - - - io.github.git-commit-id - git-commit-id-maven-plugin - 5.0.0 - - revision - - - - - - - - - - - - - org.apache.maven.plugins @@ -160,7 +113,7 @@ com.webcohesion.enunciate enunciate-maven-plugin - 2.12.0 + 2.13.3 @@ -220,6 +173,13 @@ + + + org.apache.maven.plugins + maven-site-plugin + 3.11.0 + + org.apache.maven.plugins maven-surefire-plugin diff --git a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/LegacyGraphQLAPI.java b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/LegacyGraphQLAPI.java index 29eb73d0bed..89e4c81a117 100644 --- a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/LegacyGraphQLAPI.java +++ b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/LegacyGraphQLAPI.java @@ -70,12 +70,13 @@ public Response getGraphQL( Locale locale = headers.getAcceptableLanguages().size() > 0 ? headers.getAcceptableLanguages().get(0) - : router.defaultRoutingRequest.locale; + : router.getDefaultLocale(); String query = (String) queryParameters.get("query"); Object queryVariables = queryParameters.getOrDefault("variables", null); String operationName = (String) queryParameters.getOrDefault("operationName", null); Map variables; + if (queryVariables instanceof Map) { variables = (Map) queryVariables; } @@ -115,7 +116,7 @@ public Response getGraphQL( ) { Locale locale = headers.getAcceptableLanguages().size() > 0 ? headers.getAcceptableLanguages().get(0) - : router.defaultRoutingRequest.locale; + : router.getDefaultLocale(); return LegacyGraphQLIndex.getGraphQLResponse( query, router, @@ -138,7 +139,7 @@ public Response getGraphQLBatch( List> futures = new ArrayList<>(); Locale locale = headers.getAcceptableLanguages().size() > 0 ? headers.getAcceptableLanguages().get(0) - : router.defaultRoutingRequest.locale; + : router.getDefaultLocale(); for (HashMap query : queries) { Map variables; diff --git a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/datafetchers/LegacyGraphQLQueryTypeImpl.java b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/datafetchers/LegacyGraphQLQueryTypeImpl.java index 60079c2f8f0..426ee2c171f 100644 --- a/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/datafetchers/LegacyGraphQLQueryTypeImpl.java +++ b/src/ext/java/org/opentripplanner/ext/legacygraphqlapi/datafetchers/LegacyGraphQLQueryTypeImpl.java @@ -848,7 +848,7 @@ public DataFetcher viewer() { public DataFetcher> plan() { return environment -> { LegacyGraphQLRequestContext context = environment.getContext(); - RoutingRequest request = context.getRouter().defaultRoutingRequest.clone(); + RoutingRequest request = context.getRouter().copyDefaultRoutingRequest(); CallerWithEnvironment callWith = new CallerWithEnvironment(environment); diff --git a/src/ext/java/org/opentripplanner/ext/siri/updater/SiriETGooglePubsubUpdater.java b/src/ext/java/org/opentripplanner/ext/siri/updater/SiriETGooglePubsubUpdater.java index 3e8d560b6d9..70bcab47b2d 100644 --- a/src/ext/java/org/opentripplanner/ext/siri/updater/SiriETGooglePubsubUpdater.java +++ b/src/ext/java/org/opentripplanner/ext/siri/updater/SiriETGooglePubsubUpdater.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.time.DurationFormatUtils; @@ -339,9 +340,18 @@ public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) { getTimeSinceStartupString()); } - saveResultOnGraph.execute(graph -> { - snapshotSource.applyEstimatedTimetable(graph, feedId, false, estimatedTimetableDeliveries); - }); + var f = saveResultOnGraph.execute(graph -> + snapshotSource.applyEstimatedTimetable(graph, feedId, false, estimatedTimetableDeliveries) + ); + + if (!isPrimed()) { + try { + f.get(); + } + catch (InterruptedException | ExecutionException e) { + throw new RuntimeException(e); + } + } } // Ack only after all work for the message is complete. diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLPlanner.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLPlanner.java index 896be64f9fd..45f2d29f44b 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLPlanner.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/TransmodelGraphQLPlanner.java @@ -51,11 +51,9 @@ public DataFetcherResult plan(DataFetchingEnvironment environment) PlanResponse response = new PlanResponse(); TransmodelRequestContext ctx = environment.getContext(); Router router = ctx.getRouter(); - Locale locale = router.defaultRoutingRequest.locale; RoutingRequest request = null; try { request = createRequest(environment); - locale = request.locale; RoutingResponse res = ctx.getRoutingService().route(request, router); @@ -75,6 +73,7 @@ public DataFetcherResult plan(DataFetchingEnvironment environment) response.plan = TripPlanMapper.mapTripPlan(request, List.of()); response.messages.add(new RoutingError(RoutingErrorCode.SYSTEM_ERROR, null)); } + Locale locale = request == null ? router.getDefaultLocale() : request.locale; return DataFetcherResult.newResult() .data(response) .localContext(Map.of("locale", locale)) @@ -99,10 +98,11 @@ private GenericLocation toGenericLocation(Map m) { } private RoutingRequest createRequest(DataFetchingEnvironment environment) - throws ParameterException { + throws ParameterException + { TransmodelRequestContext context = environment.getContext(); Router router = context.getRouter(); - RoutingRequest request = router.defaultRoutingRequest.clone(); + RoutingRequest request = router.copyDefaultRoutingRequest(); DataFetcherDecorator callWith = new DataFetcherDecorator(environment); diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/InfoLinkType.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/InfoLinkType.java index 74493667065..10dd2ee9888 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/InfoLinkType.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/InfoLinkType.java @@ -2,6 +2,7 @@ import graphql.Scalars; import graphql.schema.GraphQLFieldDefinition; +import graphql.schema.GraphQLNonNull; import graphql.schema.GraphQLObjectType; import org.opentripplanner.routing.alertpatch.AlertUrl; @@ -12,7 +13,7 @@ public static GraphQLObjectType create() { .name("infoLink") .field(GraphQLFieldDefinition.newFieldDefinition() .name("uri") - .type(Scalars.GraphQLString) + .type(new GraphQLNonNull(Scalars.GraphQLString)) .description("URI") .dataFetcher(environment -> { AlertUrl source = environment.getSource(); diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/MultilingualStringType.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/MultilingualStringType.java index 57b3847fc51..4e705e2906f 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/MultilingualStringType.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/framework/MultilingualStringType.java @@ -2,6 +2,7 @@ import graphql.Scalars; import graphql.schema.GraphQLFieldDefinition; +import graphql.schema.GraphQLNonNull; import graphql.schema.GraphQLObjectType; import java.util.Map; @@ -16,13 +17,13 @@ public static GraphQLObjectType create() { .field(GraphQLFieldDefinition .newFieldDefinition() .name("value") - .type(Scalars.GraphQLString) + .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> ((Map.Entry) environment.getSource()).getValue()) .build()) .field(GraphQLFieldDefinition .newFieldDefinition() .name("language") - .type(Scalars.GraphQLString) + .type(new GraphQLNonNull(Scalars.GraphQLString)) .dataFetcher(environment -> ((Map.Entry) environment.getSource()).getKey()) .build()) .build(); diff --git a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/siri/sx/PtSituationElementType.java b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/siri/sx/PtSituationElementType.java index 0c232957633..3bdf0fb3692 100644 --- a/src/ext/java/org/opentripplanner/ext/transmodelapi/model/siri/sx/PtSituationElementType.java +++ b/src/ext/java/org/opentripplanner/ext/transmodelapi/model/siri/sx/PtSituationElementType.java @@ -166,7 +166,7 @@ public static GraphQLObjectType create( .build()) .field(GraphQLFieldDefinition.newFieldDefinition() .name("infoLinks") - .type(new GraphQLList(infoLinkType)) + .type(new GraphQLList(new GraphQLNonNull(infoLinkType))) .description("Optional links to more information.") .dataFetcher(environment -> { TransitAlert alert = environment.getSource(); diff --git a/src/main/java/org/opentripplanner/api/common/Message.java b/src/main/java/org/opentripplanner/api/common/Message.java index 5255a031015..dab34e80163 100644 --- a/src/main/java/org/opentripplanner/api/common/Message.java +++ b/src/main/java/org/opentripplanner/api/common/Message.java @@ -1,6 +1,6 @@ package org.opentripplanner.api.common; -import org.opentripplanner.util.Properties; +import org.opentripplanner.util.ResourceBundleAdaptor; import java.util.Locale; @@ -31,11 +31,11 @@ public enum Message { TRIANGLE_VALUES_NOT_SET(373), ; - private Properties config = getConfig(); + private final ResourceBundleAdaptor config = new ResourceBundleAdaptor(Message.class); private final int m_id; /** enum constructors are private -- see values above */ - private Message(int id) { + Message(int id) { m_id = id; } @@ -43,28 +43,18 @@ public int getId() { return m_id; } - /** simple checker / getter of the config */ - public Properties getConfig() { - if(config == null) { - config = new Properties(Message.class); - } - return config; - } - public String get(String def, Locale l) { + public String get(Locale l) { try { - getConfig(); return config.get(name(), l); } catch(Exception e) { - Properties.LOG.warn("No entry in Message.properties file could be found for string " + name()); + ResourceBundleAdaptor.LOG.warn("No entry in Message.properties file could be found for string " + name()); + return ""; } - return def; - } - public String get(Locale l) { - return get("", l); } + public String get() { - return get("", Locale.getDefault()); + return get(Locale.getDefault()); } } diff --git a/src/main/java/org/opentripplanner/api/common/RoutingResource.java b/src/main/java/org/opentripplanner/api/common/RoutingResource.java index 538b7c25be4..e3d40bca0d5 100644 --- a/src/main/java/org/opentripplanner/api/common/RoutingResource.java +++ b/src/main/java/org/opentripplanner/api/common/RoutingResource.java @@ -709,7 +709,7 @@ public abstract class RoutingResource { */ protected RoutingRequest buildRequest(MultivaluedMap queryParameters) throws ParameterException { Router router = otpServer.getRouter(); - RoutingRequest request = router.defaultRoutingRequest.clone(); + RoutingRequest request = router.copyDefaultRoutingRequest(); // The routing request should already contain defaults, which are set when it is initialized or in the JSON // router configuration and cloned. We check whether each parameter was supplied before overwriting the default. diff --git a/src/main/java/org/opentripplanner/api/json/JSONObjectMapperProvider.java b/src/main/java/org/opentripplanner/api/json/JSONObjectMapperProvider.java index 90725bf3000..68e931f7e0f 100644 --- a/src/main/java/org/opentripplanner/api/json/JSONObjectMapperProvider.java +++ b/src/main/java/org/opentripplanner/api/json/JSONObjectMapperProvider.java @@ -1,5 +1,6 @@ package org.opentripplanner.api.json; +import com.bedatadriven.jackson.datatype.jts.JtsModule; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.databind.ObjectMapper; @@ -57,6 +58,7 @@ public JSONObjectMapperProvider() { // and named, versioned reusable modules. mapper = new ObjectMapper() .registerModule(FeedScopedIdSerializer.makeModule()) + .registerModule(new JtsModule()) .setSerializationInclusion(Include.NON_NULL); // skip null fields } diff --git a/src/main/java/org/opentripplanner/api/model/ApiRouterInfo.java b/src/main/java/org/opentripplanner/api/model/ApiRouterInfo.java index 576c6afc310..6a4bd9e3d7c 100644 --- a/src/main/java/org/opentripplanner/api/model/ApiRouterInfo.java +++ b/src/main/java/org/opentripplanner/api/model/ApiRouterInfo.java @@ -1,26 +1,22 @@ package org.opentripplanner.api.model; -import com.bedatadriven.jackson.datatype.jts.serialization.GeometrySerializer; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import java.util.Date; +import java.util.List; +import java.util.Optional; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Geometry; import org.opentripplanner.api.mapping.TraverseModeMapper; -import org.opentripplanner.routing.vehicle_rental.VehicleRentalStationService; import org.opentripplanner.routing.graph.Graph; import org.opentripplanner.routing.vehicle_parking.VehicleParkingService; +import org.opentripplanner.routing.vehicle_rental.VehicleRentalStationService; import org.opentripplanner.util.TravelOption; import org.opentripplanner.util.TravelOptionsMaker; import org.opentripplanner.util.WorldEnvelope; -import java.util.Date; -import java.util.List; -import java.util.Optional; - public class ApiRouterInfo { public String routerId; - @JsonSerialize(using= GeometrySerializer.class) public Geometry polygon; public Date buildTime; diff --git a/src/main/java/org/opentripplanner/graph_builder/module/CheckGeometryModule.java b/src/main/java/org/opentripplanner/graph_builder/module/CheckGeometryModule.java deleted file mode 100644 index 4016b80d60c..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/CheckGeometryModule.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.opentripplanner.graph_builder.module; - -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.Geometry; -import org.opentripplanner.graph_builder.DataImportIssueStore; -import org.opentripplanner.graph_builder.issues.BogusEdgeGeometry; -import org.opentripplanner.graph_builder.issues.BogusVertexGeometry; -import org.opentripplanner.graph_builder.services.GraphBuilderModule; -import org.opentripplanner.routing.graph.Edge; -import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.graph.Vertex; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -// TODO OTP2 This test might be obsolete now that there is no HopEdge anymore -/** - * Check the geometry of every edge in the graph for any bogus geometry -- - * that is, geometry with coordinates of NaN. - * This is mainly good for debugging, but probably worth keeping on for production - * because the cost is small compared to the pain of debugging. - */ -public class CheckGeometryModule implements GraphBuilderModule { - - /** An set of ids which identifies what stages this graph builder provides (i.e. streets, elevation, transit) */ - public List provides() { - return Collections.emptyList(); - } - - /** A list of ids of stages which must be provided before this stage */ - public List getPrerequisites() { - return Arrays.asList("streets"); - } - - private static final Logger LOG = LoggerFactory.getLogger(CheckGeometryModule.class); - private static final double MAX_VERTEX_SHAPE_ERROR = 150; - - @Override - public void buildGraph( - Graph graph, - HashMap, Object> extra, - DataImportIssueStore issueStore - ) { - for (Vertex gv : graph.getVertices()) { - if (Double.isNaN(gv.getCoordinate().x) || Double.isNaN(gv.getCoordinate().y)) { - LOG.warn("Vertex " + gv + " has NaN location; this will cause doom."); - issueStore.add(new BogusVertexGeometry(gv)); - } - - // TODO: This was filtered to EdgeNarratives before EdgeNarrative removal - for (Edge e : gv.getOutgoing()) { - Geometry g = e.getGeometry(); - if (g == null) { - continue; - } - for (Coordinate c : g.getCoordinates()) { - if (Double.isNaN(c.x) || Double.isNaN(c.y)) { - issueStore.add(new BogusEdgeGeometry(e)); - } - } - /* - if (e instanceof HopEdge) { - Coordinate edgeStartCoord = e.getFromVertex().getCoordinate(); - Coordinate edgeEndCoord = e.getToVertex().getCoordinate(); - Coordinate[] geometryCoordinates = g.getCoordinates(); - if (geometryCoordinates.length < 2) { - issueStore.add(new BogusEdgeGeometry(e)); - continue; - } - Coordinate geometryStartCoord = geometryCoordinates[0]; - Coordinate geometryEndCoord = geometryCoordinates[geometryCoordinates.length - 1]; - if (SphericalDistanceLibrary.distance(edgeStartCoord, geometryStartCoord) > MAX_VERTEX_SHAPE_ERROR) { - issueStore.add(new VertexShapeError(e)); - } else if (SphericalDistanceLibrary.distance(edgeEndCoord, geometryEndCoord) > MAX_VERTEX_SHAPE_ERROR) { - issueStore.add(new VertexShapeError(e)); - } - } - */ - } - } - - } - - @Override - public void checkInputs() { - //no inputs to check - } - -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/DownloadableGtfsInputSource.java b/src/main/java/org/opentripplanner/graph_builder/module/DownloadableGtfsInputSource.java deleted file mode 100644 index 6a8e3eb1cd7..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/DownloadableGtfsInputSource.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.opentripplanner.graph_builder.module; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.util.zip.ZipFile; - -import org.onebusaway.csv_entities.CsvInputSource; -import org.onebusaway.csv_entities.ZipFileCsvInputSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DownloadableGtfsInputSource implements CsvInputSource { - - private static final Logger LOG = LoggerFactory.getLogger(DownloadableGtfsInputSource.class); - - private URL url; - - private File cacheDirectory; - - private String defaultAgencyId; - - public boolean useCached = true; - - // Pattern: Decorator - private ZipFileCsvInputSource zip; - - public void setUrl(URL url) { - this.url = url; - } - - public void setCacheDirectory(File cacheDirectory) { - this.cacheDirectory = cacheDirectory; - } - - private void copyStreams(InputStream in, OutputStream out) throws IOException { - byte[] buffer = new byte[1024]; - while (true) { - int rc = in.read(buffer); - if (rc == -1) - break; - out.write(buffer, 0, rc); - } - in.close(); - out.close(); - } - - private File getTemporaryDirectory() { - - if (cacheDirectory != null) { - if (!cacheDirectory.exists()) { - if (!cacheDirectory.mkdirs()) { - throw new RuntimeException("Failed to create cache directory " + cacheDirectory); - } - } - return cacheDirectory; - } - - return new File(System.getProperty("java.io.tmpdir")); - } - - private File getPathForGtfsBundle() throws IOException { - - if (url != null) { - - File tmpDir = getTemporaryDirectory(); - String cacheFile = defaultAgencyId; - if (cacheFile == null) { - // Build a cache file based on URL - cacheFile = (url.getHost() + url.getFile()).replace("/", "_"); - } - String fileName = cacheFile + "_gtfs.zip"; - File gtfsFile = new File(tmpDir, fileName); - - if (gtfsFile.exists()) { - if (useCached) { - LOG.info("using already downloaded gtfs file: path=" + gtfsFile); - return gtfsFile; - } - LOG.info("useCached=false; GTFS will be re-downloaded." + gtfsFile); - } - - LOG.info("downloading gtfs: url=" + url + " path=" + gtfsFile); - - BufferedInputStream in = new BufferedInputStream(url.openStream()); - BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(gtfsFile)); - try { - copyStreams(in, out); - } catch (RuntimeException e) { - out.close(); - if (!gtfsFile.delete()) { - LOG.error("Failed to delete incomplete file " + gtfsFile); - } - throw e; - } - return gtfsFile; - } - - throw new IllegalStateException("DownloadableGtfsInputSource did not include an url"); - } - - private synchronized void checkIfDownloaded() throws IOException { - if (zip == null) { - zip = new ZipFileCsvInputSource(new ZipFile(getPathForGtfsBundle())); - } - } - - @Override - public boolean hasResource(String name) throws IOException { - checkIfDownloaded(); - return zip.hasResource(name); - } - - @Override - public InputStream getResource(String name) throws IOException { - checkIfDownloaded(); - return zip.getResource(name); - } - - @Override - public void close() throws IOException { - checkIfDownloaded(); - zip.close(); - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/GraphStatisticsModule.java b/src/main/java/org/opentripplanner/graph_builder/module/GraphStatisticsModule.java deleted file mode 100644 index 7614bcf03eb..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/GraphStatisticsModule.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.opentripplanner.graph_builder.module; - -import org.locationtech.jts.geom.LineString; -import org.opentripplanner.common.geometry.SphericalDistanceLibrary; -import org.opentripplanner.graph_builder.DataImportIssueStore; -import org.opentripplanner.graph_builder.services.GraphBuilderModule; -import org.opentripplanner.routing.graph.Edge; -import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.graph.Vertex; -import org.opentripplanner.util.stats.DiscreteDistribution; -import org.opentripplanner.util.stats.DiscreteDistribution.ConstantQuantifiable; -import org.opentripplanner.util.stats.DiscreteDistribution.LogQuantifiable; -import org.opentripplanner.util.stats.DiscreteDistribution.NumberQuantifiable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; - -/** - * Print statistics on geometry and edge/vertices data for a graph (number of geometry, average - * number of points, size distribution, edge names size, etc...) - */ -public class GraphStatisticsModule implements GraphBuilderModule { - - /** - * An set of ids which identifies what stages this graph builder provides (i.e. streets, - * elevation, transit) - */ - public List provides() { - return Collections.emptyList(); - } - - /** A list of ids of stages which must be provided before this stage */ - public List getPrerequisites() { - return Arrays.asList("streets"); - } - - private static final Logger LOG = LoggerFactory - .getLogger(GraphStatisticsModule.class); - - @Override - public void buildGraph( - Graph graph, - HashMap, Object> extra, - DataImportIssueStore issueStore - ) { - - DiscreteDistribution> edgeTypeDistribution = new DiscreteDistribution>(); - DiscreteDistribution> edgeNameDistribution = new DiscreteDistribution>(); - DiscreteDistribution> geomSizeDistribution = new DiscreteDistribution>(); - DiscreteDistribution> geomLenDistribution = new DiscreteDistribution>(); - - DiscreteDistribution> vertexTypeDistribution = new DiscreteDistribution>(); - DiscreteDistribution> vertexNameDistribution = new DiscreteDistribution>(); - DiscreteDistribution> vertexLabelDistribution = new DiscreteDistribution>(); - - for (Edge e : graph.getEdges()) { - edgeTypeDistribution.add(new ConstantQuantifiable(e.getClass().toString())); - edgeNameDistribution.add(new NumberQuantifiable(e.getDefaultName() == null ? 0 : e - .getDefaultName().length()), e.getDefaultName()); - if (e.getGeometry() != null) { - LineString geometry = e.getGeometry(); - geomSizeDistribution.add(new NumberQuantifiable(geometry.getNumPoints())); - double lenMeters = SphericalDistanceLibrary.fastLength(geometry); - geomLenDistribution.add(new LogQuantifiable(lenMeters, 5.0)); - } - } - for (Vertex v : graph.getVertices()) { - vertexTypeDistribution.add(new ConstantQuantifiable(v.getClass().toString())); - vertexNameDistribution.add(new NumberQuantifiable(v.getDefaultName() == null ? 0 : v - .getDefaultName().length()), v.getDefaultName()); - vertexLabelDistribution.add(new NumberQuantifiable(v.getLabel().length()), - v.getLabel()); - } - - LOG.info("Geometry size distribution (linear scale, # points):\n" - + geomSizeDistribution.toString()); - LOG.info("Geometry length distribution (log scale, meters):\n" - + geomLenDistribution.toString()); - LOG.info("Edge type distribution:\n" + edgeTypeDistribution.toString()); - LOG.info("Edge name distribution:\n" + edgeNameDistribution.toString()); - LOG.info("Vertex type distribution:\n" + vertexTypeDistribution.toString()); - LOG.info("Vertex name distribution:\n" + vertexNameDistribution.toString()); - LOG.info("Vertex label distribution:\n" + vertexLabelDistribution.toString()); - } - - @Override - public void checkInputs() { - // no inputs to check - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/CreativeNamerEditor.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/CreativeNamerEditor.java deleted file mode 100644 index 98a7c76d472..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/CreativeNamerEditor.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.opentripplanner.graph_builder.module.osm; - -import java.beans.PropertyEditorSupport; - -public class CreativeNamerEditor extends PropertyEditorSupport { - private CreativeNamer value; - - public void setAsText(String pattern) { - value = new CreativeNamer(pattern); - } - - public String getAsText() { - return value.getCreativeNamePattern(); - } - - public Object getValue() { - return value; - } - - public void setValue(Object object) { - value = (CreativeNamer) object; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/NotePropertiesEditor.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/NotePropertiesEditor.java deleted file mode 100644 index 0663d83b099..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/NotePropertiesEditor.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.opentripplanner.graph_builder.module.osm; - -import java.beans.PropertyEditorSupport; - -import org.opentripplanner.routing.services.notes.StreetNotesService; - -public class NotePropertiesEditor extends PropertyEditorSupport { - private NoteProperties value; - - public void setAsText(String pattern) { - value = new NoteProperties(pattern, StreetNotesService.ALWAYS_MATCHER); - } - - public String getAsText() { - return value.notePattern; - } - - public Object getValue() { - return value; - } - - public void setValue(Object object) { - value = (NoteProperties) object; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/osm/SafetyFeaturesEditor.java b/src/main/java/org/opentripplanner/graph_builder/module/osm/SafetyFeaturesEditor.java deleted file mode 100644 index a8732b166a0..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/osm/SafetyFeaturesEditor.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.opentripplanner.graph_builder.module.osm; - -import java.beans.PropertyEditorSupport; - -import org.opentripplanner.common.model.P2; - -public class SafetyFeaturesEditor extends PropertyEditorSupport { - private P2 value; - - public void setAsText(String safetyFeatures) { - String[] strings = safetyFeatures.split(","); - value = new P2(Double.parseDouble(strings[0]), Double.parseDouble(strings[1])); - } - - public String getAsText() { - return value.first + ", " + value.second; - } - - public Object getValue() { - return value; - } - - @SuppressWarnings("unchecked") - public void setValue(Object object) { - value = (P2) object; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/AttributeFeatureConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/AttributeFeatureConverter.java deleted file mode 100644 index c9861d847e6..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/AttributeFeatureConverter.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.nio.ByteBuffer; -import java.nio.charset.Charset; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; - -/** - * Reads a single attribute from a feature and converts it to an object */ -public class AttributeFeatureConverter implements SimpleFeatureConverter { - - private String attributeName; - private boolean decodeUTF8 = true; - - public AttributeFeatureConverter(String attributeName) { - this.attributeName = attributeName; - } - - public AttributeFeatureConverter() { - - } - - public void setAttributeName(String attributeName){ - this.attributeName = attributeName; - } - - public String getAttributeName() { - return attributeName; - } - - @SuppressWarnings({ "unchecked", "deprecation" }) - @Override - public T convert(SimpleFeature feature) { - T value = (T) feature.getAttribute(attributeName); - if (value instanceof String && decodeUTF8) { - String str = (String) value; - //decode UTF-8, irritatingly - Charset charset = Charset.forName("UTF-8"); - byte[] bytes = new byte[str.length()]; - //we have to use a deprecated method because it's the only one that works. - str.getBytes(0, str.length(), bytes, 0); - ByteBuffer bb = ByteBuffer.wrap(bytes); - value = (T) charset.decode(bb).toString(); - } - return value; - } - - public boolean isDecodeUTF8() { - return decodeUTF8; - } - - public void setDecodeUTF8(boolean decodeUTF8) { - this.decodeUTF8 = decodeUTF8; - } - -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedBicycleSafetyFeatureConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedBicycleSafetyFeatureConverter.java deleted file mode 100644 index 395b5d762d1..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedBicycleSafetyFeatureConverter.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.util.HashMap; -import java.util.Map; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.common.model.P2; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; - -/** - * Handles marking certain types of streets/bike lanes as more or less safe for bike trips. - */ -public class CaseBasedBicycleSafetyFeatureConverter implements SimpleFeatureConverter> { - - private String safetyAttributeName; - private String directionAttributeName; - - private Map safetyFeatures = new HashMap(); - private Map directions = new HashMap(); - public static final P2 oneone = new P2(1.0, 1.0); - - @Override - public P2 convert(SimpleFeature feature) { - String safetyKey = feature.getAttribute(safetyAttributeName).toString(); - Double safetyFeature = safetyFeatures.get(safetyKey); - if (safetyFeature == null) { - return oneone; - } - - int directionFeature = 3; // Default to applying the safety feature in both directions - // (useful if the dataset doesn't include direction information) - if (directionAttributeName != null) { - String directionKey = feature.getAttribute(directionAttributeName).toString(); - if (directionKey != null) { - directionFeature = directions.get(directionKey.toString()); - } - } - - return new P2((directionFeature & 0x1) == 0 ? 1.0 : safetyFeature, - (directionFeature & 0x2) == 0 ? 1.0 : safetyFeature); - } - - public CaseBasedBicycleSafetyFeatureConverter(String safetyAttributeName, - String directionAttributeName) { - this.safetyAttributeName = safetyAttributeName; - this.directionAttributeName = directionAttributeName; - } - - public CaseBasedBicycleSafetyFeatureConverter() { - } - - /** - * @param safetyAttributeName - * The name of the attribute used when calculating the feature's safety. - */ - public void setSafetyAttributeName(String safetyAttributeName) { - this.safetyAttributeName = safetyAttributeName; - } - - /** - * @param directionAttributeName - * The name of the attribute used when calculating the direction of the - * street/bikelane for which that the safety feature should apply. - */ - public void setDirectionAttributeName(String directionAttributeName) { - this.directionAttributeName = directionAttributeName; - } - - public void setSafety(Map safetyValues) { - for (Map.Entry entry : safetyValues.entrySet()) { - String attributeValue = entry.getKey(); - String featureName = entry.getValue(); - - Double safety = Double.valueOf(featureName); - addSafety(attributeValue, safety); - } - } - - public void addSafety(String attributeValue, Double safety) { - safetyFeatures.put(attributeValue, safety); - } - - /** - * Maps the direction value to a number representing the direction that the bike safety feature - * goes. The number is 1 for a safety feature that goes with the road geometry, 2 for a safety - * feature that goes against it, and 3 for a safety feature that goes both ways. - * @param directionValues - */ - public void setDirection(Map directionValues) { - for (Map.Entry entry : directionValues.entrySet()) { - String attributeValue = entry.getKey(); - String featureName = entry.getValue(); - - Integer direction = Integer.valueOf(featureName); - addDirection(attributeValue, direction); - } - } - - public void addDirection(String attributeValue, Integer direction) { - directions.put(attributeValue, direction); - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedBooleanConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedBooleanConverter.java deleted file mode 100644 index ceeefea612a..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedBooleanConverter.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.util.HashMap; -import java.util.Map; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; - -public class CaseBasedBooleanConverter implements SimpleFeatureConverter { - public boolean defaultValue = false; - - private Map values = new HashMap(); - - private String attributeName; - - public CaseBasedBooleanConverter() { - - } - - public CaseBasedBooleanConverter(String attributeName) { - this.attributeName = attributeName; - } - - public CaseBasedBooleanConverter(String attributeName, - Boolean defaultValue) { - this.attributeName = attributeName; - this.defaultValue = defaultValue; - } - - public void setAttributeName(String attributeName) { - this.attributeName = attributeName; - } - - public void setDefaultValue(Boolean defaultValue) { - this.defaultValue = defaultValue; - } - - public void setValues(Map values) { - this.values = values; - } - - @Override - public Boolean convert(SimpleFeature feature) { - String key = feature.getAttribute(attributeName).toString(); - Boolean value = values.get(key); - if (value == null) { - value = defaultValue; - } - return value; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedTraversalPermissionConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedTraversalPermissionConverter.java deleted file mode 100644 index 11a6eaf2c23..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CaseBasedTraversalPermissionConverter.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.util.HashMap; -import java.util.Map; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.common.model.P2; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; -import org.opentripplanner.routing.edgetype.StreetTraversalPermission; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Calculates street traversal permissions based upon a fixed set of cases. - * - * For example, given a shapefile that includes a DIRECTION column with data as follows: - *
- * | DIRECTION | NAME    | 
- * | ONE_WAY_F | Side St | 
- * | TWO_WAY   | Main St |
- * | ONE_WAY_B | Foo St. |
- * 
- * You could use a CaseBasedTraversalPermissionConverter to implement the following rules: - * - *

By default, all streets should be traversable by pedestrians and bicycles in both directions.

- * - *

If a street's DIRECTION attribute is ONE_WAY_F, it should be traversable by cars and bikes in - * only the forward direction and traversable by pedestrians in both directions.

- * - *

If a street's DIRECTION attribute is ONE_WAY_B, it should be traversable by cars and bikes in - * only the backward direction and traversable by pedestrians in both directions.

- * - *

If a street's DIRECTION attribute is TWO_WAY, it should be traversable by everyone in both - * directions.

- * - * - * These rules could be implemented by configuring the converter bean as follows: - *
- * {@code
- * 
- *    
- *    
- *    
- *        
- *            
- *            
- *            
- *       
- *   
- * }
- * 
- * @see org.opentripplanner.routing.edgetype.StreetTraversalPermission - * - */ -public class CaseBasedTraversalPermissionConverter implements - SimpleFeatureConverter> { - - private static Logger log = LoggerFactory.getLogger(CaseBasedBicycleSafetyFeatureConverter.class); - - private String attributeName; - - private P2 defaultPermission = P2.createPair( - StreetTraversalPermission.ALL, StreetTraversalPermission.ALL); - - private Map> _permissions = new HashMap>(); - - public CaseBasedTraversalPermissionConverter() { - - } - - public CaseBasedTraversalPermissionConverter(String attributeName) { - this.attributeName = attributeName; - } - - public CaseBasedTraversalPermissionConverter(String attributeName, - StreetTraversalPermission defaultPermission) { - this.attributeName = attributeName; - this.defaultPermission = P2.createPair(defaultPermission, defaultPermission); - } - - /** - * The name of the feature attribute to use when calculating the traversal permissions. - */ - public void setAttributeName(String attributeName) { - this.attributeName = attributeName; - } - - /** - * The default permission to use when no matching case is found for a street. - */ - public void setDefaultPermission(StreetTraversalPermission permission) { - defaultPermission = P2.createPair(permission, permission); - } - - /** - * The mapping from attribute values to permissions to use when determining a street's traversal - * permission. - */ - public void setPermissions(Map permissions) { - for (Map.Entry entry : permissions.entrySet()) { - String attributeValue = entry.getKey(); - String perms = entry.getValue(); - String[] tokens = perms.split(","); - if (tokens.length != 2) - throw new IllegalArgumentException("invalid street traversal permissions: " + perms); - - StreetTraversalPermission forward = StreetTraversalPermission.valueOf(tokens[0]); - StreetTraversalPermission reverse = StreetTraversalPermission.valueOf(tokens[1]); - addPermission(attributeValue, forward, reverse); - } - } - - public void addPermission(String attributeValue, StreetTraversalPermission forward, - StreetTraversalPermission reverse) { - _permissions.put(attributeValue, P2.createPair(forward, reverse)); - } - - @Override - public P2 convert(SimpleFeature feature) { - if (attributeName == null) { - return defaultPermission; - } - Object key = feature.getAttribute(attributeName); - if (key == null) { - return defaultPermission; - } - P2 permission = _permissions.get(key.toString()); - if (permission == null) { - log.info("unexpected permission " + key.toString()); - return defaultPermission; - } - return permission; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CompositeBooleanConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CompositeBooleanConverter.java deleted file mode 100644 index bb25c58f1bc..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CompositeBooleanConverter.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; - -/** - * A converter which is a composite of other converters. It can combine them with an "and" or "or" - * strategy. The orPermissions variable controls that. - * - * @author rob, novalis - * - */ -public class CompositeBooleanConverter implements SimpleFeatureConverter { - - private Collection> converters = new ArrayList>(); - - private boolean orPermissions = false; - - public CompositeBooleanConverter() { - } - - public CompositeBooleanConverter(SimpleFeatureConverter... converters) { - this.converters = new ArrayList>(Arrays.asList(converters)); - } - - /** - * Is the or combination strategy being used? - * - * @return whether the or combination strategy is used - */ - public boolean isOrPermissions() { - return orPermissions; - } - - public void setOrPermissions(boolean orPermissions) { - this.orPermissions = orPermissions; - } - - /** - * set the list of converters used to the passed in parameter - * - * @param converters - * list of converters to use - */ - public void setConverters( - Collection> converters) { - this.converters = converters; - } - - /** - * use the permission combination strategy to combine the results of the list of converters - */ - @Override - public Boolean convert(SimpleFeature feature) { - Boolean result = null; - for (SimpleFeatureConverter converter : converters) { - Boolean value = converter.convert(feature); - if (result == null) { - result = value; - } else { - if (orPermissions) { - result = result || value; - } else { - result = result && value; - } - } - - } - return result; - } - - /** - * add a converter to the list to be applied - * @param converter the new converter - */ - public void add(SimpleFeatureConverter converter) { - converters.add(converter); - } - -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CompositeStreetTraversalPermissionConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CompositeStreetTraversalPermissionConverter.java deleted file mode 100644 index 6d8884cd6fd..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/CompositeStreetTraversalPermissionConverter.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.util.ArrayList; -import java.util.Collection; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.common.model.P2; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; -import org.opentripplanner.routing.edgetype.StreetTraversalPermission; - -/** - * A converter which is a composite of other converters. It can combine them with an "and" or "or" - * strategy. The orPermissions variable controls that. - * - * @author rob - * - */ -public class CompositeStreetTraversalPermissionConverter implements SimpleFeatureConverter> { - - private Collection>> converters = new ArrayList>>(); - - private boolean orPermissions = false; - - public CompositeStreetTraversalPermissionConverter() { - } - - /** - * Is the or combination strategy being used? - * - * @return whether the or combination strategy is used - */ - public boolean isOrPermissions() { - return orPermissions; - } - - public void setOrPermissions(boolean orPermissions) { - this.orPermissions = orPermissions; - } - - /** - * set the list of converters used to the passed in parameter - * - * @param converters - * list of converters to use - */ - public void setConverters( - Collection>> converters) { - this.converters = converters; - } - - /** - * use the permission combination strategy to combine the results of the list of converters - */ - @Override - public P2 convert(SimpleFeature feature) { - P2 result = null; - for (SimpleFeatureConverter> converter : converters) { - P2 value = converter.convert(feature); - if (result == null) { - result = value; - } else { - StreetTraversalPermission first, second; - if (orPermissions) { - first = result.first.add(value.first); - second = result.second.add(value.second); - } else { - first = StreetTraversalPermission.get(result.first.code & value.first.code); - second = StreetTraversalPermission.get(result.second.code & value.second.code); - } - result = new P2(first, second); - } - - } - return result; - } - - /** - * add a converter to the list to be applied - * @param converter the new converter - */ - public void add(SimpleFeatureConverter> converter) { - converters.add(converter); - } - -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/DirectSafetyReader.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/DirectSafetyReader.java deleted file mode 100644 index 74eec5b290b..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/DirectSafetyReader.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.common.model.P2; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; - -/* - * Read safety factors directly from shapefiles (contributed by Guillaume Barreau) - */ -public class DirectSafetyReader implements SimpleFeatureConverter> { - private String safetyAttributeName; - - public static final P2 oneone = new P2(1.0, 1.0); - - @Override - public P2 convert(SimpleFeature feature) { - Double d = (Double) feature.getAttribute(safetyAttributeName); - if (d == null) { - return oneone; - } - return new P2(d, d); - } - - public void setSafetyAttributeName(String safetyAttributeName) { - this.safetyAttributeName = safetyAttributeName; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/FeatureIdConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/FeatureIdConverter.java deleted file mode 100644 index c44cbe8543c..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/FeatureIdConverter.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; - -public class FeatureIdConverter implements SimpleFeatureConverter { - - @Override - public String convert(SimpleFeature feature) { - return feature.getID(); - } - -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/JoinedFeatureConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/JoinedFeatureConverter.java deleted file mode 100644 index 2bf1208526b..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/JoinedFeatureConverter.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.io.IOException; -import java.util.HashMap; - -import org.geotools.data.FeatureSource; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.FeatureIterator; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opentripplanner.graph_builder.services.shapefile.FeatureSourceFactory; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This is a simple feature converter that gets features from a secondary feature source. This is - * useful if you have (say) bike lane data in another file. - */ -public class JoinedFeatureConverter implements SimpleFeatureConverter { - - private static Logger log = LoggerFactory.getLogger(JoinedFeatureConverter.class); - - private SimpleFeatureConverter converter; - - private String joinedKey; - - private String mainKey; - - private FeatureSource joinedSource; - - private HashMap cache; - - public JoinedFeatureConverter() { - } - - public JoinedFeatureConverter(String mainKey, String joinedKey, - SimpleFeatureConverter converter, - FeatureSource joinedSource) { - this.mainKey = mainKey; - this.joinedKey = joinedKey; - this.converter = converter; - this.joinedSource = joinedSource; - } - - @Override - public T convert(SimpleFeature feature) { - ensureCached(); - String mainKeyValue = toHashableString(feature.getAttribute(this.mainKey)); - if (mainKeyValue == null) { - log.warn("Feature " + feature.getID() + " has null value for its mainKey (" + mainKey + ")"); - return null; - } - SimpleFeature joinedFeature = cache.get(mainKeyValue); - - if (joinedFeature == null) { - return null; - } else { - return converter.convert(joinedFeature); - } - } - - /** We have to cache all the features in the supplemental file, because - * if we try to load them on the fly, GeoTools wigs out. - */ - private void ensureCached() { - if (cache != null) { - return; - } - cache = new HashMap(); - try { - FeatureCollection features = joinedSource - .getFeatures(); - FeatureIterator it = features.features(); - while (it.hasNext()) { - SimpleFeature feature = it.next(); - String joinedKeyValue = toHashableString(feature.getAttribute(joinedKey)); - if (joinedKeyValue != null) { - cache.put(joinedKeyValue, feature); - } else { - log.warn("Feature " + feature.getID() + " has null value for its joinedKey (" + joinedKey + ")"); - } - } - it.close(); - - } catch (IOException e) { - throw new RuntimeException("Could not cache values for joined shapefile", e); - } - } - - /** - * Convert a feature value to a String for hashing. We use this instead of simply calling - * toString to avoid issues when the column types for these features are slightly different. See - * http://opentripplanner.org/ticket/226 - * - * @param keyValue - * @return a string to use as the hash key - */ - private String toHashableString(Object keyValue) { - if (keyValue == null) { - return null; - } - if (keyValue instanceof Number) { - keyValue = ((Number)keyValue).doubleValue(); - } - return keyValue.toString(); - } - - public void setConverter(SimpleFeatureConverter converter) { - this.converter = converter; - } - - /** - * The name of the attribute in the joined feature source to use as the join key. - */ - public void setJoinedKey(String joinedKey) { - this.joinedKey = joinedKey; - } - - /** - * The name of the attribute in the main feature source to use as the join key. - */ - public void setMainKey(String mainKey) { - this.mainKey = mainKey; - } - - public void setJoinedSourceFactory(FeatureSourceFactory factory) { - this.joinedSource = factory.getFeatureSource(); - } - - public void setJoinedSource(FeatureSource joinedSource) { - this.joinedSource = joinedSource; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/NullBooleanConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/NullBooleanConverter.java deleted file mode 100644 index 08b61594e70..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/NullBooleanConverter.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import org.opengis.feature.simple.SimpleFeature; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; - -/** - * A converter which converts null-valued attributes to either true or false (and all others to the other) - * - * @author novalis - * - */ -public class NullBooleanConverter implements SimpleFeatureConverter { - - private String attributeName; - - private boolean nullIsTrue = false; - - public NullBooleanConverter() { - } - - public NullBooleanConverter(String attributeName, boolean nullIsTrue) { - this.attributeName = attributeName; - this.nullIsTrue = nullIsTrue; - } - - @Override - public Boolean convert(SimpleFeature feature) { - Object value = feature.getAttribute(attributeName); - - if (value == null || value.equals("")) { - return nullIsTrue; - } else { - return !nullIsTrue; - } - } - - /** - * @param attributeName the attribute name to set - */ - public void setAttributeName(String attributeName) { - this.attributeName = attributeName; - } - - /** - * @return the attribute name - */ - public String getAttributeName() { - return attributeName; - } - - /** - * @param nullIsTrue whether a null value for this attribue converts to false - */ - public void setNullIsTrue(boolean nullIsTrue) { - this.nullIsTrue = nullIsTrue; - } - - /** - * @return whether a null value for this attribute converts to true - */ - public boolean getNullIsTrue() { - return nullIsTrue; - } - -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileFeatureSourceFactoryImpl.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileFeatureSourceFactoryImpl.java deleted file mode 100644 index 101b60f84dd..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileFeatureSourceFactoryImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.io.File; - -import org.geotools.data.FeatureSource; -import org.geotools.data.shapefile.ShapefileDataStore; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opentripplanner.graph_builder.services.shapefile.FeatureSourceFactory; - -public class ShapefileFeatureSourceFactoryImpl implements FeatureSourceFactory { - - private File path; - private ShapefileDataStore dataStore; - - public ShapefileFeatureSourceFactoryImpl() { - - } - - public ShapefileFeatureSourceFactoryImpl(File path) { - this.path = path; - } - - public void setPath(File path) { - this.path = path; - } - - @Override - public FeatureSource getFeatureSource() { - - try { - dataStore = new ShapefileDataStore(path.toURI().toURL()); - - String typeNames[] = dataStore.getTypeNames(); - String typeName = typeNames[0]; - - return dataStore.getFeatureSource(typeName); - } catch (Exception ex) { - throw new IllegalStateException("error creating feature source from shapefile: path=" - + path, ex); - } - } - - @Override - public void cleanup() { - dataStore.dispose(); - } - - @Override - public void checkInputs() { - if (!path.canRead()) { - throw new RuntimeException("Can't read Shapefile path: " + path); - } - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileStreetModule.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileStreetModule.java deleted file mode 100644 index f5aad8ec8f9..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileStreetModule.java +++ /dev/null @@ -1,335 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import org.geotools.data.FeatureSource; -import org.geotools.data.Query; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.FeatureIterator; -import org.geotools.geometry.jts.JTS; -import org.geotools.referencing.ReferencingFactoryFinder; -import org.geotools.util.factory.Hints; -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.LineString; -import org.locationtech.jts.geom.MultiLineString; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.referencing.crs.CRSAuthorityFactory; -import org.opengis.referencing.crs.CoordinateReferenceSystem; -import org.opentripplanner.common.geometry.GeometryUtils; -import org.opentripplanner.common.model.P2; -import org.opentripplanner.graph_builder.DataImportIssueStore; -import org.opentripplanner.graph_builder.services.DefaultStreetEdgeFactory; -import org.opentripplanner.graph_builder.services.GraphBuilderModule; -import org.opentripplanner.graph_builder.services.StreetEdgeFactory; -import org.opentripplanner.graph_builder.services.shapefile.FeatureSourceFactory; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; -import org.opentripplanner.model.StreetNote; -import org.opentripplanner.routing.edgetype.StreetEdge; -import org.opentripplanner.routing.edgetype.StreetTraversalPermission; -import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.services.notes.StreetNotesService; -import org.opentripplanner.routing.vertextype.IntersectionVertex; -import org.opentripplanner.util.NonLocalizedString; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -/** - * Loads a shapefile into an edge-based graph. - * - */ -public class ShapefileStreetModule implements GraphBuilderModule { - private static Logger log = LoggerFactory.getLogger(ShapefileStreetModule.class); - - private FeatureSourceFactory featureSourceFactory; - - private ShapefileStreetSchema schema; - - public StreetEdgeFactory edgeFactory = new DefaultStreetEdgeFactory(); - - public List provides() { - return Arrays.asList("streets"); - } - - public List getPrerequisites() { - return Collections.emptyList(); - } - - public void setFeatureSourceFactory(FeatureSourceFactory factory) { - featureSourceFactory = factory; - } - - public void setSchema(ShapefileStreetSchema schema) { - this.schema = schema; - } - - @Override - public void buildGraph( - Graph graph, - HashMap, Object> extra, - DataImportIssueStore issueStore - ) { - - try { - - FeatureSource featureSource = featureSourceFactory - .getFeatureSource(); - CoordinateReferenceSystem sourceCRS = featureSource.getInfo().getCRS(); - - Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); - CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", - hints); - CoordinateReferenceSystem worldCRS = factory - .createCoordinateReferenceSystem("EPSG:4326"); - - Query query = new Query(); - query.setCoordinateSystem(sourceCRS); - query.setCoordinateSystemReproject(worldCRS); - - FeatureCollection features = featureSource - .getFeatures(query); - - features = featureSource.getFeatures(query); - - HashMap> intersectionNameToId = new HashMap>(); - - SimpleFeatureConverter streetIdConverter = schema.getIdConverter(); - SimpleFeatureConverter streetNameConverter = schema.getNameConverter(); - SimpleFeatureConverter> permissionConverter = schema - .getPermissionConverter(); - SimpleFeatureConverter noteConverter = schema.getNoteConverter(); - - HashMap intersectionsByLocation = - new HashMap(); - - SimpleFeatureConverter> safetyConverter = schema.getBicycleSafetyConverter(); - - SimpleFeatureConverter slopeOverrideCoverter = schema.getSlopeOverrideConverter(); - - SimpleFeatureConverter featureSelector = schema.getFeatureSelector(); - - // Keep track of features that are duplicated so we don't have duplicate streets - Set seen = new HashSet(); - - List featureList = new ArrayList(); - FeatureIterator it2 = features.features(); - while (it2.hasNext()) { - SimpleFeature feature = it2.next(); - if (featureSelector != null && ! featureSelector.convert(feature)) { - continue; - } - featureList.add(feature); - } - it2.close(); - it2 = null; - - HashMap> coordinateToStreetNames = getCoordinatesToStreetNames(featureList); - - for (SimpleFeature feature : featureList) { - if (feature.getDefaultGeometry() == null) { - log.warn("feature has no geometry: " + feature.getIdentifier()); - continue; - } - LineString geom = toLineString((Geometry) feature.getDefaultGeometry()); - - Object o = streetIdConverter.convert(feature); - String label = "" + o; - if (o != null && seen.contains(label)) { - continue; - } - seen.add(label); - String name = streetNameConverter.convert(feature); - Coordinate[] coordinates = geom.getCoordinates(); - - if (coordinates.length < 2) { - //not a real linestring - log.warn("Bad geometry for street with label " + label + " name " + name); - continue; - } - - // this rounding is a total hack, to work around - // http://jira.codehaus.org/browse/GEOT-2811 - Coordinate startCoordinate = new Coordinate( - Math.round(coordinates[0].x * 1048576) / 1048576.0, Math - .round(coordinates[0].y * 1048576) / 1048576.0); - Coordinate endCoordinate = new Coordinate(Math - .round(coordinates[coordinates.length - 1].x * 1048576) / 1048576.0, Math - .round(coordinates[coordinates.length - 1].y * 1048576) / 1048576.0); - - String startIntersectionName = getIntersectionName(coordinateToStreetNames, - intersectionNameToId, startCoordinate); - - if (startIntersectionName == "null") { - log.warn("No intersection name for " + name); - } - - String endIntersectionName = getIntersectionName(coordinateToStreetNames, - intersectionNameToId, endCoordinate); - - IntersectionVertex startIntersection = intersectionsByLocation.get(startCoordinate); - if (startIntersection == null) { - startIntersection = new IntersectionVertex(graph, startIntersectionName, startCoordinate.x, - startCoordinate.y, new NonLocalizedString(startIntersectionName)); - intersectionsByLocation.put(startCoordinate, startIntersection); - } - - IntersectionVertex endIntersection = intersectionsByLocation.get(endCoordinate); - if (endIntersection == null) { - endIntersection = new IntersectionVertex(graph, endIntersectionName, endCoordinate.x, - endCoordinate.y, new NonLocalizedString(endIntersectionName)); - intersectionsByLocation.put(endCoordinate, endIntersection); - } - - double length = 0; - for (int i = 0; i < coordinates.length - 1; ++i) { - length += JTS.orthodromicDistance(coordinates[i], - coordinates[i + 1], worldCRS); - } - P2 permissions = permissionConverter.convert(feature); - - // TODO Set appropriate car speed from shapefile source. - StreetEdge street = edgeFactory.createEdge(startIntersection, endIntersection, - geom, new NonLocalizedString(name), length, permissions.first, false); - LineString reversed = (LineString) geom.reverse(); - StreetEdge backStreet = edgeFactory.createEdge(endIntersection, startIntersection, - reversed, new NonLocalizedString(name), length, permissions.second, true); - backStreet.shareData(street); - - if (noteConverter != null) { - String note = noteConverter.convert(feature); - if (note != null && note.length() > 0) { - StreetNote noteAlert = new StreetNote(note); - graph.streetNotesService.addStaticNote( - street, - noteAlert, - StreetNotesService.ALWAYS_MATCHER - ); - graph.streetNotesService.addStaticNote( - backStreet, - noteAlert, - StreetNotesService.ALWAYS_MATCHER - ); - } - } - - boolean slopeOverride = slopeOverrideCoverter.convert(feature); - street.setSlopeOverride(slopeOverride); - backStreet.setSlopeOverride(slopeOverride); - - if (safetyConverter != null) { - P2 safetyFactors = safetyConverter.convert(feature); - if (safetyFactors != null) { - street.setBicycleSafetyFactor(safetyFactors.first.floatValue()); - backStreet.setBicycleSafetyFactor(safetyFactors.second.floatValue()); - } - } - } - } catch (Exception ex) { - throw new IllegalStateException("error loading shapefile street data", ex); - } finally { - featureSourceFactory.cleanup(); - } - } - - private HashMap> getCoordinatesToStreetNames( - List features) { - HashMap> coordinateToStreets = new HashMap>(); - SimpleFeatureConverter streetNameConverter = schema.getNameConverter(); - - SimpleFeatureConverter featureSelector = schema.getFeatureSelector(); - Iterator it = features.iterator(); - while (it.hasNext()) { - SimpleFeature feature = it.next(); - if (featureSelector != null && !featureSelector.convert(feature)) { - continue; - } - if (feature.getDefaultGeometry() == null) { - log.warn("feature has no geometry: " + feature.getIdentifier()); - continue; - } - LineString geom = toLineString((Geometry) feature.getDefaultGeometry()); - - for (Coordinate coord : geom.getCoordinates()) { - // this rounding is a total hack, to work around - // http://jira.codehaus.org/browse/GEOT-2811 - Coordinate rounded = new Coordinate(Math.round(coord.x * 1048576) / 1048576.0, Math - .round(coord.y * 1048576) / 1048576.0); - - TreeSet streets = coordinateToStreets.get(rounded); - if (streets == null) { - streets = new TreeSet(); - coordinateToStreets.put(rounded, streets); - } - String streetName = streetNameConverter.convert(feature); - if (streetName == null) { - throw new IllegalStateException("Unexpectedly got null for a street name for feature at " + coord); - } - streets.add(streetName); - } - } - - return coordinateToStreets; - } - - private String getIntersectionName(HashMap> coordinateToStreets, - HashMap> intersectionNameToId, - Coordinate coordinate) { - - TreeSet streets = coordinateToStreets.get(coordinate); - if (streets == null) { - return "null"; - } - - //TODO: localize this and return localized string - String intersection = streets.first() + " at " + streets.last(); - - HashMap possibleIntersections = intersectionNameToId.get(intersection); - if (possibleIntersections == null) { - possibleIntersections = new HashMap(); - possibleIntersections.put(coordinate, 1); - intersectionNameToId.put(intersection, possibleIntersections); - return intersection; - } - Integer index = possibleIntersections.get(coordinate); - if (index == null) { - int max = 0; - for (Integer value : possibleIntersections.values()) { - if (value > max) - max = value; - } - possibleIntersections.put(coordinate, max + 1); - index = max + 1; - } - if (index > 1) { - intersection += " #" + possibleIntersections.get(coordinate); - } - return intersection; - } - - private LineString toLineString(Geometry g) { - if (g instanceof LineString) { - return (LineString) g; - } else if (g instanceof MultiLineString) { - MultiLineString ml = (MultiLineString) g; - - Coordinate[] coords = ml.getCoordinates(); - return GeometryUtils.getGeometryFactory().createLineString(coords); - } else { - throw new RuntimeException("found a geometry feature that's not a linestring: " + g); - } - } - - @Override - public void checkInputs() { - featureSourceFactory.checkInputs(); - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileStreetSchema.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileStreetSchema.java deleted file mode 100644 index 2c0329bb271..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/ShapefileStreetSchema.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import org.opentripplanner.common.model.P2; -import org.opentripplanner.graph_builder.services.shapefile.SimpleFeatureConverter; -import org.opentripplanner.routing.edgetype.StreetTraversalPermission; - -public class ShapefileStreetSchema { - - private SimpleFeatureConverter idConverter = new FeatureIdConverter(); - - private SimpleFeatureConverter nameConverter; - - private SimpleFeatureConverter> permissionConverter = new CaseBasedTraversalPermissionConverter(); - - private SimpleFeatureConverter> bicycleSafetyConverter = null; - - private SimpleFeatureConverter slopeOverrideConverter = new CaseBasedBooleanConverter(); - - private SimpleFeatureConverter featureSelector = null; - - private SimpleFeatureConverter noteConverter = null; - - public SimpleFeatureConverter getIdConverter() { - return idConverter; - } - - /** - * Sets the converter which gets IDs from features. - * - * @see ShapefileStreetSchema#setIdAttribute - */ - public void setIdConverter(SimpleFeatureConverter idConverter) { - this.idConverter = idConverter; - } - - /** - * The ID attribute is used to uniquely identify street segments. This is useful if a given - * street segment appears multiple times in a shapefile. - */ - public void setIdAttribute(String attributeName) { - this.idConverter = new AttributeFeatureConverter(attributeName); - } - - public SimpleFeatureConverter getNameConverter() { - return nameConverter; - } - - public void setNameAttribute(String attributeName) { - this.nameConverter = new AttributeFeatureConverter(attributeName); - } - - /** - * The name converter gets the street name from a feature. - */ - public void setNameConverter(SimpleFeatureConverter nameConverter) { - this.nameConverter = nameConverter; - } - - /** - * The permission converter gets the {@link StreetTraversalPermission} for a street segment and - * its reverse. - * - * @return - */ - public SimpleFeatureConverter> getPermissionConverter() { - return permissionConverter; - } - - public void setPermissionConverter( - SimpleFeatureConverter> permissionConverter) { - this.permissionConverter = permissionConverter; - } - - /** - * The permission converter gets the bicycle safety factor for a street segment and its reverse. - * The safety factor is 1.0 for an ordinary street. For streets which are more or less safe for - * bicycles, the safety factor is the number of miles you would have to bike on an ordinary - * street to have the same odds of dying as if you biked one mile on this street. For example, - * if bike lanes reduce risk by a factor of 3, the safety factor would be 0.33... - * - */ - public void setBicycleSafetyConverter(SimpleFeatureConverter> safetyConverter) { - this.bicycleSafetyConverter = safetyConverter; - } - - public SimpleFeatureConverter> getBicycleSafetyConverter() { - return bicycleSafetyConverter; - } - - /** - * @see setSlopeOverrideConverter - * @return - */ - public SimpleFeatureConverter getSlopeOverrideConverter() { - return slopeOverrideConverter; - } - - /** - * The slope override converter returns true if the slope found from NED is should be ignored - * (for instance, on bridges and tunnels) - * - * @param slopeOverrideConverter - */ - public void setSlopeOverrideConverter(SimpleFeatureConverter slopeOverrideConverter) { - this.slopeOverrideConverter = slopeOverrideConverter; - } - - /** - * @param featureSelector - * A featureSelector returns true if a feature is a street, and false otherwise. - * Useful for centerline files that also have non-streets, such as political - * boundaries or coastlines - */ - public void setFeatureSelector(SimpleFeatureConverter featureSelector) { - this.featureSelector = featureSelector; - } - - /** - * @see setFeatureSelector - * @return the current feature selector - */ - public SimpleFeatureConverter getFeatureSelector() { - return featureSelector; - } - - public void setNoteConverter(SimpleFeatureConverter noteConverter) { - this.noteConverter = noteConverter; - } - - public SimpleFeatureConverter getNoteConverter() { - return noteConverter; - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/StringAttributeFeatureConverter.java b/src/main/java/org/opentripplanner/graph_builder/module/shapefile/StringAttributeFeatureConverter.java deleted file mode 100644 index 4ee7e7e2ad3..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/shapefile/StringAttributeFeatureConverter.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import org.opengis.feature.simple.SimpleFeature; - -/** - * A converter for extracting string attributes from features. The converter supports the - * specification of a default value, which is useful if you are reading from data sources that might - * contain blank (or null) values (e.g., if you're reading street name values, you might want to - * default to "Unnamed street" instead of null or " "). - * - * @author nicholasbs - * - */ -public class StringAttributeFeatureConverter extends AttributeFeatureConverter { - - private String defaultValue; - - public StringAttributeFeatureConverter() { - - } - - public StringAttributeFeatureConverter(String attributeName, String defaultValue) { - super(attributeName); - this.defaultValue = defaultValue; - } - - public StringAttributeFeatureConverter(String attributeName) { - super(attributeName); - defaultValue = null; - } - - /** - * The default value to assign to features with null or empty (" ") values. - */ - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - @Override - public String convert(SimpleFeature feature) { - String attr = (String) feature.getAttribute(getAttributeName()); - // Since dBase (used in shapefiles) has poor/no null support, null strings are sometimes - // stored as a single space " " - if (attr == null || attr.equals(" ")) { - attr = defaultValue; - } - return attr; - } - -} diff --git a/src/main/java/org/opentripplanner/graph_builder/module/vehicle/VehicleParkingModule.java b/src/main/java/org/opentripplanner/graph_builder/module/vehicle/VehicleParkingModule.java deleted file mode 100644 index 48ca78238a1..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/module/vehicle/VehicleParkingModule.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.opentripplanner.graph_builder.module.vehicle; - -import org.opentripplanner.graph_builder.DataImportIssueStore; -import org.opentripplanner.graph_builder.services.GraphBuilderModule; -import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.vehicle_parking.VehicleParking; -import org.opentripplanner.routing.vehicle_parking.VehicleParkingHelper; -import org.opentripplanner.routing.vehicle_parking.VehicleParkingService; -import org.opentripplanner.updater.DataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collection; -import java.util.HashMap; - -/** - * This graph builder allow one to statically build bike or car park using the same source as the dynamic - * vehicle parking updater. - */ -public class VehicleParkingModule implements GraphBuilderModule { - - private final static Logger LOG = LoggerFactory.getLogger(VehicleParkingModule.class); - - private DataSource dataSource; - - public void setDataSource(DataSource dataSource) { - this.dataSource = dataSource; - } - - @Override - public void buildGraph( - Graph graph, - HashMap, Object> extra, - DataImportIssueStore issueStore - ) { - - LOG.info("Building vehicle parking from static source..."); - VehicleParkingService service = graph.getService(VehicleParkingService.class, true); - if (!dataSource.update()) { - LOG.warn("No vehicle parks found from the data source."); - return; - } - Collection vehicleParks = dataSource.getUpdates(); - - for (VehicleParking vehicleParking : vehicleParks) { - service.addVehicleParking(vehicleParking); - VehicleParkingHelper.linkVehicleParkingToGraph(graph, vehicleParking); - } - LOG.info("Created " + vehicleParks.size() + " vehicle parks."); - } - - @Override - public void checkInputs() { - } -} diff --git a/src/main/java/org/opentripplanner/graph_builder/services/shapefile/SimpleFeatureConverter.java b/src/main/java/org/opentripplanner/graph_builder/services/shapefile/SimpleFeatureConverter.java deleted file mode 100644 index c09f50a51f3..00000000000 --- a/src/main/java/org/opentripplanner/graph_builder/services/shapefile/SimpleFeatureConverter.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.opentripplanner.graph_builder.services.shapefile; - -import org.opengis.feature.simple.SimpleFeature; - -/** - * Interface for converters from an opengis @{link org.opengis.feature.simple.SimpleFeature} - * to an object of type T - * - * @param the type to convert to. - */ -public interface SimpleFeatureConverter { - public T convert(SimpleFeature feature); -} diff --git a/src/main/java/org/opentripplanner/openstreetmap/BinaryOpenStreetMapProvider.java b/src/main/java/org/opentripplanner/openstreetmap/BinaryOpenStreetMapProvider.java index c8e485087a1..b4449746be3 100644 --- a/src/main/java/org/opentripplanner/openstreetmap/BinaryOpenStreetMapProvider.java +++ b/src/main/java/org/opentripplanner/openstreetmap/BinaryOpenStreetMapProvider.java @@ -1,5 +1,10 @@ package org.opentripplanner.openstreetmap; +import com.google.common.base.MoreObjects; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import org.openstreetmap.osmosis.osmbinary.file.BlockInputStream; import org.opentripplanner.datastore.DataSource; import org.opentripplanner.datastore.FileType; @@ -9,11 +14,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - /** * Parser for the OpenStreetMap PBF format. Parses files in three passes: * First the relations, then the ways, then the nodes are also loaded. @@ -22,18 +22,18 @@ public class BinaryOpenStreetMapProvider { private static final Logger LOG = LoggerFactory.getLogger(BinaryOpenStreetMapProvider.class); private final DataSource source; - private final boolean cacheDataImMem; + private final boolean cacheDataInMem; private byte[] cachedBytes = null; /** For tests */ - public BinaryOpenStreetMapProvider(File file, boolean cacheDataImMem) { - this(new FileDataSource(file, FileType.OSM), cacheDataImMem); + public BinaryOpenStreetMapProvider(File file, boolean cacheDataInMem) { + this(new FileDataSource(file, FileType.OSM), cacheDataInMem); } - public BinaryOpenStreetMapProvider(DataSource source, boolean cacheDataImMem) { + public BinaryOpenStreetMapProvider(DataSource source, boolean cacheDataInMem) { this.source = source; - this.cacheDataImMem = cacheDataImMem; + this.cacheDataInMem = cacheDataInMem; } public void readOSM(OSMDatabase osmdb) { @@ -69,7 +69,7 @@ private void parsePhase(BinaryOpenStreetMapParser parser, OsmParserPhase phase) } private InputStream createInputStream(OsmParserPhase phase) { - if(cacheDataImMem) { + if(cacheDataInMem) { if(cachedBytes == null) { cachedBytes = source.asBytes(); } @@ -89,8 +89,13 @@ private static InputStream track(OsmParserPhase phase, long size, InputStream in ); } + @Override public String toString() { - return "BinaryFileBasedOpenStreetMapProviderImpl(" + source.path() + ")"; + return MoreObjects.toStringHelper(this) + .add("source", source) + .add("cacheDataInMem", cacheDataInMem) + .add("cachedBytes", cachedBytes) + .toString(); } public void checkInputs() { diff --git a/src/main/java/org/opentripplanner/routing/core/StateFactory.java b/src/main/java/org/opentripplanner/routing/core/StateFactory.java deleted file mode 100644 index 50e7b8130b7..00000000000 --- a/src/main/java/org/opentripplanner/routing/core/StateFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.opentripplanner.routing.core; - -/** - * Factory interface for creating initial {@link State} objects. Useful if you wish to override the - * default {@link State} or {@link StateData} implementation. - * - * @author bdferris - */ -public interface StateFactory { - public State createState(long time); -} diff --git a/src/main/java/org/opentripplanner/routing/impl/LoggingTraverseVisitor.java b/src/main/java/org/opentripplanner/routing/impl/LoggingTraverseVisitor.java deleted file mode 100644 index 7745b7daaaf..00000000000 --- a/src/main/java/org/opentripplanner/routing/impl/LoggingTraverseVisitor.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.opentripplanner.routing.impl; - -import org.opentripplanner.routing.algorithm.astar.TraverseVisitor; -import org.opentripplanner.routing.core.State; -import org.opentripplanner.routing.graph.Edge; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class LoggingTraverseVisitor implements TraverseVisitor { - private static final Logger LOG = LoggerFactory.getLogger(LoggingTraverseVisitor.class); - - @Override - public void visitEdge(Edge edge, State state) { - String nextName = edge.getDefaultName(); - LOG.info("Traversing edge {}", nextName); - } - - @Override - public void visitVertex(State state) { - LOG.info("Visiting {}", state); - } - - @Override - public void visitEnqueue(State state) { - LOG.info("Enqueing {}", state); - } -} diff --git a/src/main/java/org/opentripplanner/routing/impl/PathWeightComparator.java b/src/main/java/org/opentripplanner/routing/impl/PathWeightComparator.java deleted file mode 100644 index 2db39a16805..00000000000 --- a/src/main/java/org/opentripplanner/routing/impl/PathWeightComparator.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opentripplanner.routing.impl; - -import java.util.Comparator; - -import org.opentripplanner.routing.spt.GraphPath; - -public class PathWeightComparator implements Comparator { - - @Override - public int compare(GraphPath o1, GraphPath o2) { - return (int) (o1.getWeight() - o2.getWeight()); - } - -} diff --git a/src/main/java/org/opentripplanner/routing/services/OnBoardDepartService.java b/src/main/java/org/opentripplanner/routing/services/OnBoardDepartService.java deleted file mode 100644 index a005ce35224..00000000000 --- a/src/main/java/org/opentripplanner/routing/services/OnBoardDepartService.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.opentripplanner.routing.services; - -import java.io.Serializable; - -import org.opentripplanner.routing.core.RoutingContext; -import org.opentripplanner.routing.graph.Vertex; - -/** - * Graph service for depart-on-board mode. - * - * @author laurent - */ -public interface OnBoardDepartService extends Serializable { - - public abstract Vertex setupDepartOnBoard(RoutingContext ctx); -} diff --git a/src/main/java/org/opentripplanner/routing/util/NullExtraEdges.java b/src/main/java/org/opentripplanner/routing/util/NullExtraEdges.java deleted file mode 100644 index 239d14b4f36..00000000000 --- a/src/main/java/org/opentripplanner/routing/util/NullExtraEdges.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.opentripplanner.routing.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import org.opentripplanner.routing.graph.Edge; -import org.opentripplanner.routing.graph.Vertex; - - -/** - * - * NullExtraEdges is used to speed up checks for extra edges in the (common) case - * where there are none. Extra edges come from StreetLocationFinder, where - * they represent the edges between a location on a street segment and the - * corners at the ends of that segment. - */ -public class NullExtraEdges implements Map> { - - @Override - public void clear() { - } - - @Override - public boolean containsKey(Object arg0) { - return false; - } - - @Override - public boolean containsValue(Object arg0) { - return false; - } - - @Override - public Set>> entrySet() { - return null; - } - - @Override - public ArrayList get(Object arg0) { - return null; - } - - @Override - public boolean isEmpty() { - return false; - } - - @Override - public Set keySet() { - return null; - } - - @Override - public ArrayList put(Vertex arg0, ArrayList arg1) { - return null; - } - - @Override - public void putAll(Map> arg0) { - } - - @Override - public ArrayList remove(Object arg0) { - return null; - } - - @Override - public int size() { - return 0; - } - - @Override - public Collection> values() { - return null; - } -} \ No newline at end of file diff --git a/src/main/java/org/opentripplanner/standalone/server/Router.java b/src/main/java/org/opentripplanner/standalone/server/Router.java index e48b7379643..621bfec5236 100644 --- a/src/main/java/org/opentripplanner/standalone/server/Router.java +++ b/src/main/java/org/opentripplanner/standalone/server/Router.java @@ -6,6 +6,8 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.FileAppender; import io.micrometer.core.instrument.Metrics; +import java.time.Instant; +import java.util.Locale; import org.opentripplanner.ext.transmodelapi.TransmodelAPI; import org.opentripplanner.inspector.TileRendererManager; import org.opentripplanner.routing.algorithm.raptoradapter.transit.TransitLayer; @@ -30,6 +32,7 @@ public class Router { private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(Router.class); + private final RoutingRequest defaultRoutingRequest; public final Graph graph; public final RouterConfig routerConfig; public final RaptorConfig raptorConfig; @@ -46,18 +49,13 @@ public class Router { /** Inspector/debug services */ public TileRendererManager tileRendererManager; - /** - * A RoutingRequest containing default parameters that will be cloned when handling each - * request. - */ - public RoutingRequest defaultRoutingRequest; - /** A graphical window that is used for visualizing search progress (debugging). */ public GraphVisualizer graphVisualizer = null; public Router(Graph graph, RouterConfig routerConfig) { this.graph = graph; this.routerConfig = routerConfig; + this.defaultRoutingRequest = routerConfig.routingRequestDefaults(); this.raptorConfig = new RaptorConfig<>( routerConfig.raptorTuningParameters(), Metrics.globalRegistry @@ -75,7 +73,6 @@ public Router(Graph graph, RouterConfig routerConfig) { */ public void startup() { this.tileRendererManager = new TileRendererManager(this.graph); - this.defaultRoutingRequest = routerConfig.routingRequestDefaults(); if (routerConfig.requestLogFile() != null) { this.requestLogger = createLogger(routerConfig.requestLogFile()); @@ -124,6 +121,23 @@ public void startup() { } } + /** + * A RoutingRequest containing default parameters that will be cloned when handling each + * request. + */ + public RoutingRequest copyDefaultRoutingRequest() { + var copy = this.defaultRoutingRequest.clone(); + copy.setDateTime(Instant.now()); + return copy; + } + + /** + * Return the default routing request locale(without cloning the request). + */ + public Locale getDefaultLocale() { + return this.defaultRoutingRequest.locale; + } + /** Shut down this router when evicted or (auto-)reloaded. Stop any real-time updater threads. */ public void shutdown() { GraphUpdaterConfigurator.shutdownGraph(this.graph); diff --git a/src/main/java/org/opentripplanner/transit/raptor/rangeraptor/transit/TripHelper.java b/src/main/java/org/opentripplanner/transit/raptor/rangeraptor/transit/TripHelper.java deleted file mode 100644 index 63d70efdffd..00000000000 --- a/src/main/java/org/opentripplanner/transit/raptor/rangeraptor/transit/TripHelper.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.opentripplanner.transit.raptor.rangeraptor.transit; - -import org.opentripplanner.transit.raptor.api.transit.RaptorTripSchedule; - -public class TripHelper { - - - - - - - int boardTime(RaptorTripSchedule trip, int earliestBoardTime, int stopIndex) { - return 0; - - - - - - } - - -} diff --git a/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java b/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java index e692064c8d5..b9a6c7f8067 100644 --- a/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java +++ b/src/main/java/org/opentripplanner/updater/GraphUpdaterManager.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.Predicate; @@ -129,8 +130,8 @@ public void stop() { } @Override - public void execute(GraphWriterRunnable runnable) { - scheduler.submit(() -> { + public Future execute(GraphWriterRunnable runnable) { + return scheduler.submit(() -> { try { runnable.run(graph); } catch (Exception e) { diff --git a/src/main/java/org/opentripplanner/updater/WriteToGraphCallback.java b/src/main/java/org/opentripplanner/updater/WriteToGraphCallback.java index 78ff76142b9..7c79e2fe986 100644 --- a/src/main/java/org/opentripplanner/updater/WriteToGraphCallback.java +++ b/src/main/java/org/opentripplanner/updater/WriteToGraphCallback.java @@ -1,5 +1,7 @@ package org.opentripplanner.updater; +import java.util.concurrent.Future; + public interface WriteToGraphCallback { /** @@ -11,5 +13,5 @@ public interface WriteToGraphCallback { * * @param runnable is a graph writer runnable */ - void execute(GraphWriterRunnable runnable); + Future execute(GraphWriterRunnable runnable); } diff --git a/src/main/java/org/opentripplanner/util/IntUtils.java b/src/main/java/org/opentripplanner/util/IntUtils.java deleted file mode 100644 index 06ccd705144..00000000000 --- a/src/main/java/org/opentripplanner/util/IntUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.opentripplanner.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class IntUtils { - private static final Logger LOG = LoggerFactory.getLogger(IntUtils.class); - - public static int getIntFromString(String input) { - int retVal = 0; - - Integer n = getIntegerFromString(input); - if (n != null) { - retVal = n.intValue(); - } - else if (input != null) { - retVal = input.hashCode(); - } - - return retVal; - } - - public static Integer getIntegerFromString(String input) { - try { - return new Integer(input); - } catch (Exception e) { - try { - String in = input.replaceAll("\\D", ""); - return new Integer(in); - } catch (Exception ee) { - return null; - } - } - } - - public static long getLongFromString(String input) { - return getLongFromString(input, -111); - } - - public static long getLongFromString(String input, long def) { - try { - return new Long(input); - } catch (Exception e) { - LOG.info("Not a big deal...going to return default value", e); - return def; - } - } -} diff --git a/src/main/java/org/opentripplanner/util/Properties.java b/src/main/java/org/opentripplanner/util/Properties.java deleted file mode 100644 index bfc31bab6e0..00000000000 --- a/src/main/java/org/opentripplanner/util/Properties.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.opentripplanner.util; - -import java.text.MessageFormat; -import java.util.Locale; -import java.util.ResourceBundle; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The purpose of Properties is to easily read a ResourceBundel (set of localized .properties files), and get the named contents. - * Goes really well with an enumerated type (@see org.opentripplanner.api.ws.Message) - */ -public class Properties { - - public static final Logger LOG = LoggerFactory.getLogger(Properties.class); - - private final String bundle; - - public Properties() { - this(Properties.class); - } - - public Properties(Class c) { - bundle = c.getSimpleName(); - } - - public Properties(String bundle) { - this.bundle = bundle; - } - - /** - * static .properties resource loader - * will first look for a resource org.opentripplaner.blah.blah.blah.ClassName.properties. - * if that doesn't work, it searches for ClassName.properties. - */ - public static ResourceBundle getBundle(String name, Locale l) { - try { - return ResourceBundle.getBundle(name, l); - } - catch(Exception e) { - LOG.error("Uh oh...no .properties file could be found, so things are most definately not going to turn out well!!!", e); - } - return null; - } - - public synchronized String get(String name, Locale l) throws Exception { - ResourceBundle rb = getBundle(bundle, l); - return rb.getString(name); - } - public synchronized String get(String name) throws Exception { - ResourceBundle rb = getBundle(bundle, Locale.getDefault()); - return rb.getString(name); - } - - - public String get(String name, String def, Locale l) { - String retVal = null; - try { - retVal = get(name, l); - } - catch (Exception ex) { } - - if (retVal == null || retVal.length() < 1) { - retVal = def; - } - - return retVal; - } - public String get(String name, String def) { - return get(name, def, Locale.getDefault()); - } - - - public boolean get(String name, boolean def, Locale l) { - boolean retVal = def; - try { - String s = get(name, l); - if (s.toLowerCase().equals("true")) - retVal = true; - } catch (Exception e) { - retVal = def; - } - - return retVal; - } - public boolean get(String name, boolean def) { - return get(name, def, Locale.getDefault()); - } - - - public int get(String name, int def, Locale l) { - String tmp = get(name, Integer.toString(def), l); - return IntUtils.getIntFromString(tmp); - } - public int get(String name, int def) { - return get(name, def, Locale.getDefault()); - } - - public long get(String name, long def, Locale l) { - String tmp = get(name, Long.toString(def), l); - return IntUtils.getLongFromString(tmp); - } - public long get(String name, long def) { - return get(name, def, Locale.getDefault()); - } - - - public boolean is(String name, Locale l) { - boolean retVal = false; - try { - String r = get(name, l); - if (r != null && r.equalsIgnoreCase("true")) - retVal = true; - } catch (Exception ex) { - } - - return retVal; - } - public boolean is(String name) { - return is(name, Locale.getDefault()); - } - - - public synchronized String format(String name, Locale l, Object... args) { - try { - ResourceBundle rb = getBundle(bundle, l); - return MessageFormat.format(rb.getString(name), args); - } catch (Exception e) { - LOG.warn("couldn't find / format property " + name + "; returning null", e); - } - - return null; - } - public synchronized String format(String name, Object... args) { - return format(name, Locale.getDefault(), args); - } -} diff --git a/src/main/java/org/opentripplanner/util/ResourceBundleAdaptor.java b/src/main/java/org/opentripplanner/util/ResourceBundleAdaptor.java new file mode 100644 index 00000000000..c28ed7fe239 --- /dev/null +++ b/src/main/java/org/opentripplanner/util/ResourceBundleAdaptor.java @@ -0,0 +1,44 @@ +package org.opentripplanner.util; + +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The purpose of Properties is to easily read a ResourceBundle (set of localized .properties files), and get the named contents. + * Goes really well with an enumerated type (@see org.opentripplanner.api.ws.Message) + */ +public class ResourceBundleAdaptor { + + public static final Logger LOG = LoggerFactory.getLogger(ResourceBundleAdaptor.class); + + private final String bundle; + + public ResourceBundleAdaptor(Class c) { + bundle = c.getSimpleName(); + } + + + public synchronized String get(String name, Locale l) throws Exception { + ResourceBundle rb = getBundle(bundle, l); + return rb.getString(name); + } + + /** + * static .properties resource loader + * will first look for a resource org.opentripplaner.blah.blah.blah.ClassName.properties. + * if that doesn't work, it searches for ClassName.properties. + */ + private static ResourceBundle getBundle(String name, Locale l) { + try { + return ResourceBundle.getBundle(name, l); + } + catch(MissingResourceException e) { + LOG.error("Uh oh...no .properties file could be found, so things are most definately not going to turn out well!!!", e); + throw e; + } + } +} diff --git a/src/main/java/org/opentripplanner/util/stats/DiscreteDistribution.java b/src/main/java/org/opentripplanner/util/stats/DiscreteDistribution.java deleted file mode 100644 index 667c2da5304..00000000000 --- a/src/main/java/org/opentripplanner/util/stats/DiscreteDistribution.java +++ /dev/null @@ -1,198 +0,0 @@ -package org.opentripplanner.util.stats; - -import static java.util.Locale.ROOT; - -import com.google.common.collect.Multiset; -import com.google.common.collect.SortedMultiset; -import com.google.common.collect.TreeMultiset; -import java.text.MessageFormat; - -interface Quantifiable> extends Comparable { - - public double doubleValue(); -} - -/** - * A discrete distribution on K (aka frequency). - */ -public class DiscreteDistribution> { - - public static class NumberQuantifiable implements - Quantifiable> { - - private K num; - - public NumberQuantifiable(K num) { - this.num = num; - } - - @Override - public int hashCode() { - return num.hashCode(); - } - - @Override - public boolean equals(Object another) { - if (another instanceof NumberQuantifiable) { - @SuppressWarnings("unchecked") - NumberQuantifiable other = (NumberQuantifiable) another; - return other.num.equals(this.num); - } - return false; - } - - @Override - public int compareTo(NumberQuantifiable o) { - // This should be safe, even for integers - return Double.compare(this.num.doubleValue(), o.num.doubleValue()); - } - - @Override - public double doubleValue() { - return num.doubleValue(); - } - - @Override - public String toString() { - return num.toString(); - } - } - - public static class LogQuantifiable implements - Quantifiable> { - - private int log; - - private double mult; - - private K k; - - public LogQuantifiable(K k, double mult) { - this.mult = mult; - this.k = k; - log = (int) Math.round(Math.log(k.doubleValue()) * mult); - } - - @Override - public int hashCode() { - return log; - } - - @Override - public boolean equals(Object another) { - if (another instanceof LogQuantifiable) { - @SuppressWarnings("unchecked") - LogQuantifiable anotherLog = (LogQuantifiable) another; - return anotherLog.log == this.log; - } - return false; - } - - @Override - public int compareTo(LogQuantifiable o) { - // Do not compare on k here! - return Integer.compare(log, o.log); - } - - @Override - public double doubleValue() { - return k.doubleValue(); - } - - @Override - public String toString() { - double min = Math.exp(log / mult); - double max = Math.exp((log + 1) / mult); - return String.format(ROOT, "%.2f-%.2f", min, max); - } - } - - public static class ConstantQuantifiable> implements - Quantifiable> { - - private K k; - - public ConstantQuantifiable(K k) { - this.k = k; - } - - @Override - public int hashCode() { - return k.hashCode(); - } - - @Override - public boolean equals(Object another) { - if (another instanceof ConstantQuantifiable) { - @SuppressWarnings("unchecked") - ConstantQuantifiable other = (ConstantQuantifiable) another; - return other.k.equals(this.k); - } - return false; - } - - @Override - public int compareTo(ConstantQuantifiable o) { - return k.compareTo(o.k); - } - - @Override - public double doubleValue() { - return 1.0; - } - - @Override - public String toString() { - return k.toString(); - } - } - - private double totK = 0.0; - - private SortedMultiset distribution = TreeMultiset.create(); - - public void add(K k) { - totK += k.doubleValue(); - distribution.add(k, 1); - } - - public void add(K k, String sample) { - totK += k.doubleValue(); - if (distribution.count(k) == 0) { - System.out.println(k.doubleValue() + " => " + sample); - } - distribution.add(k, 1); - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - int totCount = distribution.size(); - int minCount = Integer.MAX_VALUE; - int maxCount = 0; - for (Multiset.Entry e : distribution.entrySet()) { - int count = e.getCount(); - if (count < minCount) - minCount = count; - if (count > maxCount) - maxCount = count; - } - sb.append(String.format("K: Total: %.02f, avg: %.02f, min: %s, max: %s\n", totK, totK * 1.0 - / totCount, distribution.firstEntry().getElement(), distribution.lastEntry() - .getElement())); - sb.append(String.format("C: Total: %d, min: %d, max: %d\n", totCount, minCount, maxCount)); - for (Multiset.Entry e : distribution.entrySet()) { - sb.append(MessageFormat.format("{0} : {1} {2}\n", e.getElement().toString(), - chart(e.getCount(), maxCount, 60), e.getCount())); - } - sb.append("----------------------------------------------------------------"); - return sb.toString(); - } - - private String chart(int x, int xMax, int len) { - StringBuffer retval = new StringBuffer(); - for (int i = 0; i < Math.round(x * 1.0 * len / xMax); i++) - retval.append("*"); - return retval.toString(); - } -} \ No newline at end of file diff --git a/src/test/java/org/opentripplanner/api/resource/MessageTest.java b/src/test/java/org/opentripplanner/api/resource/MessageTest.java new file mode 100644 index 00000000000..6ab7d6b645b --- /dev/null +++ b/src/test/java/org/opentripplanner/api/resource/MessageTest.java @@ -0,0 +1,52 @@ +package org.opentripplanner.api.resource; + +import static java.util.Locale.ENGLISH; +import static java.util.Locale.FRENCH; +import static java.util.Locale.GERMANY; +import static java.util.Locale.forLanguageTag; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.util.Locale; +import org.junit.jupiter.api.Test; +import org.opentripplanner.api.common.Message; + +public class MessageTest { + + @Test + public void testLanguages() { + Locale es = forLanguageTag("es"); + Locale hu = forLanguageTag("hu"); + Locale nl = forLanguageTag("nl"); + + + for (var m : Message.values()) { + String name = m.name(); + System.out.println(name); + + assertFalse(m.get(ENGLISH).isBlank(), "Message code missing(ENGLISH): " + name); + assertFalse(m.get(GERMANY).isBlank(), "Message code missing(GERMANY): " + name); + assertFalse(m.get(FRENCH).isBlank(), "Message code missing(FRENCH): " + name); + assertFalse(m.get(es).isBlank(), "Message code missing(ES): " + name); + assertFalse(m.get(hu).isBlank(), "Message code missing(HU): " + name); + assertFalse(m.get(nl).isBlank(), "Message code missing(NL): " + name); + } + } + + @Test + public void testDefaultLanguage() { + // Keep default locale so we can set it back after the test is done + Locale sysDefaultLocale = Locale.getDefault(); + try { + // Force default to make test work on non-US machines + Locale.setDefault(Locale.GERMANY); + + for (var m : Message.values()) { + assertEquals(m.get(), m.get(GERMANY)); + } + } + finally { + Locale.setDefault(sysDefaultLocale); + } + } +} diff --git a/src/test/java/org/opentripplanner/api/resource/TestMessages.java b/src/test/java/org/opentripplanner/api/resource/TestMessages.java deleted file mode 100644 index afbb6fd52c8..00000000000 --- a/src/test/java/org/opentripplanner/api/resource/TestMessages.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.opentripplanner.api.resource; - -import junit.framework.TestCase; -import org.opentripplanner.api.common.Message; - -import java.util.Locale; - -public class TestMessages extends TestCase { - - public void testLanguages() { - // Keep default locale so we can set it back after the test is done - Locale sysDefaultLocale = Locale.getDefault(); - try { - // Force default to make test work on non-US machines - Locale.setDefault(new Locale("en", "US")); - - String e = Message.PATH_NOT_FOUND.get(); - String f = Message.PATH_NOT_FOUND.get(Locale.CANADA_FRENCH); - String s = Message.PATH_NOT_FOUND.get(new Locale("es")); - - TestCase.assertNotNull(e); - TestCase.assertNotNull(f); - TestCase.assertNotNull(s); - TestCase.assertNotSame(e, f); - TestCase.assertNotSame(e, s); - TestCase.assertNotSame(f, s); - } - finally { - Locale.setDefault(sysDefaultLocale); - } - } -} diff --git a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/CompositeConverterTest.java b/src/test/java/org/opentripplanner/graph_builder/module/shapefile/CompositeConverterTest.java deleted file mode 100644 index 1d7ddd97690..00000000000 --- a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/CompositeConverterTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import junit.framework.TestCase; - -import org.opentripplanner.common.model.P2; -import org.opentripplanner.routing.edgetype.StreetTraversalPermission; - - -public class CompositeConverterTest extends TestCase { - - private CompositeStreetTraversalPermissionConverter converter; - private StubSimpleFeature stubFeature; - private CaseBasedTraversalPermissionConverter caseConverter1; - private CaseBasedTraversalPermissionConverter caseConverter2; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - converter = new CompositeStreetTraversalPermissionConverter(); - - stubFeature = new StubSimpleFeature(); - stubFeature.addAttribute("trafdir", "1"); - stubFeature.addAttribute("streettype", "nicestreet"); - - caseConverter1 = new CaseBasedTraversalPermissionConverter("trafdir"); - caseConverter2 = new CaseBasedTraversalPermissionConverter("streettype"); - converter.add(caseConverter1); - converter.add(caseConverter2); - } - - public void testPermissionAggregationAnd() throws Exception { - caseConverter1.addPermission("1", StreetTraversalPermission.ALL, StreetTraversalPermission.ALL); - caseConverter2.addPermission("nicestreet", StreetTraversalPermission.ALL, StreetTraversalPermission.NONE); - - P2 result = converter.convert(stubFeature); - assertEquals(new P2(StreetTraversalPermission.ALL, StreetTraversalPermission.NONE), result); - } - - public void testPermissionAggregationOr() throws Exception { - converter.setOrPermissions(true); - - caseConverter1.addPermission("1", StreetTraversalPermission.NONE, StreetTraversalPermission.ALL); - caseConverter2.addPermission("nicestreet", StreetTraversalPermission.ALL, StreetTraversalPermission.ALL); - - P2 result = converter.convert(stubFeature); - assertEquals(new P2(StreetTraversalPermission.ALL, StreetTraversalPermission.ALL), result); - } - - public void testWalkingBiking() throws Exception { - converter.setOrPermissions(true); - caseConverter1.addPermission("1", StreetTraversalPermission.PEDESTRIAN, StreetTraversalPermission.PEDESTRIAN); - caseConverter2.addPermission("nicestreet", StreetTraversalPermission.BICYCLE, StreetTraversalPermission.BICYCLE); - P2 result = converter.convert(stubFeature); - assertEquals(new P2(StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE, StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE), result); - } - - public void testAllCars() throws Exception { - caseConverter1.addPermission("1", StreetTraversalPermission.ALL, StreetTraversalPermission.ALL); - caseConverter2.addPermission("nicestreet", StreetTraversalPermission.CAR, StreetTraversalPermission.CAR); - P2 result = converter.convert(stubFeature); - assertEquals(new P2(StreetTraversalPermission.CAR, StreetTraversalPermission.CAR), result); - } - -} \ No newline at end of file diff --git a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/StubSimpleFeature.java b/src/test/java/org/opentripplanner/graph_builder/module/shapefile/StubSimpleFeature.java deleted file mode 100644 index 93d7597852a..00000000000 --- a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/StubSimpleFeature.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.opengis.feature.GeometryAttribute; -import org.opengis.feature.IllegalAttributeException; -import org.opengis.feature.Property; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.feature.type.AttributeDescriptor; -import org.opengis.feature.type.Name; -import org.opengis.filter.identity.FeatureId; -import org.opengis.geometry.BoundingBox; - -/** - * A stubbed out simple feature used for tests. Currently only the getAttribute is actually stubbed - * out, and the return can be controlled with the addAttribute method. - * - * @author rob - * - */ -public class StubSimpleFeature implements SimpleFeature { - - private Map attributeMap = new HashMap(); - - public void addAttribute(String name, Object value) { - attributeMap.put(name, value); - } - - @Override - public Object getAttribute(String name) { - return this.attributeMap.get(name); - } - - @Override - public Object getAttribute(Name name) { - return null; - } - - @Override - public Object getAttribute(int index) throws IndexOutOfBoundsException { - return null; - } - - @Override - public int getAttributeCount() { - return 0; - } - - @Override - public List getAttributes() { - return null; - } - - @Override - public Object getDefaultGeometry() { - return null; - } - - @Override - public SimpleFeatureType getFeatureType() { - return null; - } - - @Override - public String getID() { - return null; - } - - @Override - public SimpleFeatureType getType() { - return null; - } - - @Override - public void setAttribute(String name, Object value) { - } - - @Override - public void setAttribute(Name name, Object value) { - } - - @Override - public void setAttribute(int index, Object value) throws IndexOutOfBoundsException { - } - - @Override - public void setAttributes(List values) { - } - - @Override - public void setAttributes(Object[] values) { - } - - @Override - public void setDefaultGeometry(Object geometry) { - } - - @Override - public BoundingBox getBounds() { - return null; - } - - @Override - public GeometryAttribute getDefaultGeometryProperty() { - return null; - } - - @Override - public FeatureId getIdentifier() { - return null; - } - - @Override - public void setDefaultGeometryProperty(GeometryAttribute geometryAttribute) { - - } - - @Override - public Collection getProperties() { - return null; - } - - @Override - public Collection getProperties(Name name) { - return null; - } - - @Override - public Collection getProperties(String name) { - return null; - } - - @Override - public Property getProperty(Name name) { - return null; - } - - @Override - public Property getProperty(String name) { - return null; - } - - @Override - public Collection getValue() { - return null; - } - - @Override - public void setValue(Collection values) { - } - - @Override - public void validate() throws IllegalAttributeException { - } - - @Override - public AttributeDescriptor getDescriptor() { - return null; - } - - @Override - public Name getName() { - return null; - } - - @Override - public Map getUserData() { - return null; - } - - @Override - public boolean isNillable() { - return false; - } - - @Override - public void setValue(Object newValue) { - } - -} diff --git a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/TestCaseBasedTraversalPermissionConverter.java b/src/test/java/org/opentripplanner/graph_builder/module/shapefile/TestCaseBasedTraversalPermissionConverter.java deleted file mode 100644 index 9e5c307c986..00000000000 --- a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/TestCaseBasedTraversalPermissionConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import org.opentripplanner.common.model.P2; -import org.opentripplanner.routing.edgetype.StreetTraversalPermission; - -import junit.framework.TestCase; - - -public class TestCaseBasedTraversalPermissionConverter extends TestCase { - /* - * Test for ticket #273: ttp://opentripplanner.org/ticket/273 - */ - public void testDefaultValueForNullEntry() throws Exception { - StubSimpleFeature feature = new StubSimpleFeature(); - feature.addAttribute("DIRECTION", null); - - CaseBasedTraversalPermissionConverter converter = new CaseBasedTraversalPermissionConverter(); - converter.setDefaultPermission(StreetTraversalPermission.PEDESTRIAN); - - converter.addPermission("FOO", StreetTraversalPermission.ALL, StreetTraversalPermission.ALL); - - assertEquals(new P2(StreetTraversalPermission.PEDESTRIAN, StreetTraversalPermission.PEDESTRIAN), converter.convert(feature)); - } -} diff --git a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/TestShapefileStreetGraphBuilderImpl.java b/src/test/java/org/opentripplanner/graph_builder/module/shapefile/TestShapefileStreetGraphBuilderImpl.java deleted file mode 100644 index 61fa4f38fd5..00000000000 --- a/src/test/java/org/opentripplanner/graph_builder/module/shapefile/TestShapefileStreetGraphBuilderImpl.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.opentripplanner.graph_builder.module.shapefile; - -import junit.framework.TestCase; -import org.junit.Test; -import org.locationtech.jts.geom.Coordinate; -import org.opentripplanner.routing.algorithm.astar.AStar; -import org.opentripplanner.routing.api.request.RoutingRequest; -import org.opentripplanner.routing.core.TraverseMode; -import org.opentripplanner.routing.core.TraverseModeSet; -import org.opentripplanner.routing.edgetype.StreetTraversalPermission; -import org.opentripplanner.routing.graph.Edge; -import org.opentripplanner.routing.graph.Graph; -import org.opentripplanner.routing.graph.Vertex; -import org.opentripplanner.routing.spt.ShortestPathTree; - -import java.io.File; -import java.net.URL; -import java.util.HashMap; - -public class TestShapefileStreetGraphBuilderImpl extends TestCase { - - @Test - public void testBasic() throws Exception { - Graph gg = new Graph(); - - URL resource = getClass().getResource("nyc_streets/streets.shp"); - File file = null; - if (resource != null) { - file = new File(resource.getFile()); - } - if (file == null || !file.exists()) { - System.out.println("No New York City basemap; skipping; see comment here for details"); - /* - * This test requires the New York City base map. Place it among the source - * resources and Eclipse should automatically copy it over to the target directory. - * Once you have prepared these files, you may need to 'refresh' in Eclipse's package - * explorer to force Eclipse to notice the new resources. - * - * Recent versions of this map are available only in Arcview Geodatabase format. - * For conversion to a Shapefile, you will need the archived MapInfo version at: - * http://www.nyc.gov/html/dcp/html/bytes/bytesarchive.shtml#lion - * Download the MapInfo file of Lion version 10B. - * - * This must then be converted to a ShapeFile as follows: - * cd opentripplanner-graph-builder/src/test/resources/org/opentripplanner/graph_builder/module/shapefile - * mkdir nyc_streets (this is where we will store the shapefile) - * unzip nyc_lion10ami.zip (this should place zipfile contents in a ./lion directory) - * ogr2ogr -f 'ESRI Shapefile' nyc_streets/streets.shp lion/MNLION1.tab - * ogr2ogr -update -append -f 'ESRI Shapefile' nyc_streets lion/SILION1.tab -nln streets - * ogr2ogr -update -append -f 'ESRI Shapefile' nyc_streets lion/QNLION1.tab -nln streets - * ogr2ogr -update -append -f 'ESRI Shapefile' nyc_streets lion/BKLION1.tab -nln streets - * ogr2ogr -update -append -f 'ESRI Shapefile' nyc_streets lion/BXLION1.tab -nln streets - * - * Testing also requires NYC Subway data in GTFS in the same location: - * wget http://data.topplabs.org/data/mta_nyct_subway/subway.zip - */ - return; - } - - ShapefileFeatureSourceFactoryImpl factory = new ShapefileFeatureSourceFactoryImpl(file); - - ShapefileStreetSchema schema = new ShapefileStreetSchema(); - schema.setIdAttribute("SegmentID"); - schema.setNameAttribute("Street"); - - /* only featuretyp=0 are streets */ - CaseBasedBooleanConverter selector = new CaseBasedBooleanConverter("FeatureTyp", false); - - HashMap streets = new HashMap(); - streets.put("0", true); - selector.setValues(streets); - schema.setFeatureSelector(selector); - - /* street directions */ - CaseBasedTraversalPermissionConverter perms = new CaseBasedTraversalPermissionConverter( - "TrafDir", StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE); - - perms.addPermission("W", StreetTraversalPermission.ALL, - StreetTraversalPermission.PEDESTRIAN); - perms.addPermission("A", StreetTraversalPermission.PEDESTRIAN, - StreetTraversalPermission.ALL); - perms.addPermission("T", StreetTraversalPermission.ALL, StreetTraversalPermission.ALL); - - schema.setPermissionConverter(perms); - - ShapefileStreetModule loader = new ShapefileStreetModule(); - loader.setFeatureSourceFactory(factory); - loader.setSchema(schema); - - loader.buildGraph(gg, new HashMap, Object>()); - - //find start and end vertices - Vertex start = null; - Vertex end = null; - Vertex carlton = null; - - Coordinate vanderbiltAtPark = new Coordinate(-73.969178, 40.676785); - Coordinate grandAtLafayette = new Coordinate(-73.999095, 40.720005); - Coordinate carltonAtPark = new Coordinate(-73.972347, 40.677447); - - for (Vertex v : gg.getVertices()) { - if (v.getCoordinate().distance(vanderbiltAtPark) < 0.00005) { - /* we need the correct vanderbilt at park. In this case, - * that's the one facing west on vanderbilt. - */ - int numParks = 0; - int numCarltons = 0; - for (Edge e: v.getOutgoing()) { - if (e.getToVertex().getDefaultName().contains("PARK")) { - numParks ++; - } - if (e.getToVertex().getDefaultName().contains("CARLTON")) { - numCarltons ++; - } - } - if (numCarltons != 2 || numParks != 1) { - continue; - } - start = v; - } else if (v.getCoordinate().distance(grandAtLafayette) < 0.0001) { - end = v; - } else if (v.getCoordinate().distance(carltonAtPark) < 0.00005) { - /* we need the correct carlton at park. In this case, - * that's the one facing west. - */ - int numFlatbushes = 0; - int numParks = 0; - - for (Edge e: v.getOutgoing()) { - if (e.getToVertex().getDefaultName().contains("FLATBUSH")) { - numFlatbushes ++; - } - if (e.getToVertex().getDefaultName().contains("PARK")) { - numParks ++; - } - } - if (numFlatbushes != 2 || numParks != 1) { - continue; - } - carlton = v; - } - } - assertNotNull(start); - assertNotNull(end); - assertNotNull(carlton); - - assertEquals(3, start.getDegreeOut()); - assertEquals(3, start.getDegreeIn()); - - AStar aStar = new AStar(); - RoutingRequest opt = new RoutingRequest(); - opt.setRoutingContext(gg, start, end); - ShortestPathTree spt = aStar.getShortestPathTree(opt); - assertNotNull(spt); - - //test that the option to walk bikes on the first or last segment works - - opt = new RoutingRequest(new TraverseModeSet(TraverseMode.BICYCLE)); - - //Real live cyclists tell me that they would prefer to ride around the long way than to - //walk their bikes the short way. If we slow down the default biking speed, that will - //force a change in preferences. - opt.bikeSpeed = 2; - - opt.setRoutingContext(gg, start, carlton); - spt = aStar.getShortestPathTree(opt); - assertNotNull(spt); - /* commented out as bike walking is not supported */ - /* - GraphPath path = spt.getPath(carlton.vertex); - assertNotNull(path); - assertTrue(path.edges.size() <= 3); - - wo.setArriveBy(true); - spt = AStar.getShortestPathTreeBack(gg, start.vertex, carlton.vertex, new State(0), wo); - assertNotNull(spt); - - path = spt.getPath(carlton.vertex); - assertTrue(path.edges.size() <= 3); - */ - } -} diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java b/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java index 8cfd3d0c4c1..8f402b86171 100644 --- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java +++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java @@ -87,7 +87,7 @@ protected Router getRouter() { protected RoutingRequest createTestRequest(int year, int month, int day, int hour, int minute, int second) { Router router = getRouter(); - RoutingRequest request = router.defaultRoutingRequest.clone(); + RoutingRequest request = router.copyDefaultRoutingRequest(); request.setDateTime(TestUtils.dateInstant(router.graph.getTimeZone().getID(), year, month, day, hour, minute, second)); request.maxTransfers = 6; request.numItineraries = 6; diff --git a/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java b/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java index c96d09af265..c4d63526e88 100644 --- a/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java +++ b/src/test/java/org/opentripplanner/updater/vehicle_parking/VehicleParkingUpdaterTest.java @@ -4,6 +4,8 @@ import static org.mockito.Mockito.when; import java.util.List; +import java.util.concurrent.Future; +import com.google.common.util.concurrent.Futures; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -98,8 +100,9 @@ public GraphUpdaterMock( } @Override - public void execute(GraphWriterRunnable runnable) { + public Future execute(GraphWriterRunnable runnable) { runnable.run(graph); + return Futures.immediateVoidFuture(); } } diff --git a/src/test/resources/Message.properties b/src/test/resources/Message.properties deleted file mode 100644 index 861735188c3..00000000000 --- a/src/test/resources/Message.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Strings used by the Messages.java enum (i.e., if that enum's name changes, the properties files' names must change) -# - -# PLANNER ERROR MESSAGES -PLAN_OK = Success -SYSTEM_ERROR = We're sorry. The trip planner is temporarily unavailable. Please try again later. - -OUTSIDE_BOUNDS = Trip is not possible. You might be trying to plan a trip outside the map data boundary. -REQUEST_TIMEOUT = The trip planner is taking way too long to process your request. Please try again later. -BOGUS_PARAMETER = The request has errors that the server is not willing or able to process. -PATH_NOT_FOUND = Trip is not possible. Please check that your plan is within the bound of the map. -NO_TRANSIT_TIMES = No transit times available. The date may be past or too far in the future or there may not be transit service for your trip at the time you chose. -GEOCODE_FROM_NOT_FOUND = Origin is unknown. Can you be a bit more descriptive? -GEOCODE_TO_NOT_FOUND = Destination is unknown. Can you be a bit more descriptive? -GEOCODE_FROM_TO_NOT_FOUND = Both origin and destination are unknown. Can you be a bit more descriptive? -TOO_CLOSE = Origin is within a trivial distance of the destination. - -GEOCODE_FROM_AMBIGUOUS = The trip planner is unsure of the location you want to start from. Please select from the following options, or be more specific. -GEOCODE_TO_AMBIGUOUS = The trip planner is unsure of the destination you want to go to. Please select from the following options, or be more specific. -GEOCODE_FROM_TO_AMBIGUOUS = Both origin and destination are ambiguous. Please select from the following options, or be more specific. \ No newline at end of file diff --git a/src/test/resources/Message_de.properties b/src/test/resources/Message_de.properties deleted file mode 100644 index 46275a62c86..00000000000 --- a/src/test/resources/Message_de.properties +++ /dev/null @@ -1,21 +0,0 @@ -PLAN_OK = Success -SYSTEM_ERROR = Es tut uns leid, leider steht der Trip-Planer momentan nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt nochmal. - -OUTSIDE_BOUNDS = Planung nicht möglich. Vielleicht versuchen sie einen Plan außerhalb der Kartengrenzen zu planen. -REQUEST_TIMEOUT = Der Trip-Planner braucht viel zu lange um die Anfrage zu bearbeiten. Bitte versuchen Sie es zu einem späteren Zeitpunkt nochmal. -BOGUS_PARAMETER = Die Anfrage ist fehlerhaft so dass sie der Server nicht bearbeiten möchte oder kann. -PATH_NOT_FOUND = Planung nicht möglich. Ihr Start- oder Endpunkt könnte nicht erreichbar sein. Bitte stellen sie sicher, dass ihre Anfrage innerhalb der Kartendaten ist. -NO_TRANSIT_TIMES = Keine Fahrzeiten verfügbar. Das Datum kann zu weit in der Vergangenheit oder zu weit in der Zukunft liegen oder es gibt keinen Verkehrsbetrieb zu dem von Ihnen gewählten Zeitpunkt. - -GEOCODE_FROM_NOT_FOUND = Ausgangspunkt unbekannt. Können Sie bitte ein Wenig detailierter beschreiben? -GEOCODE_TO_NOT_FOUND = Fahrtziel unbekannt. Können Sie bitte ein Wenig detailierter beschreiben? -GEOCODE_FROM_TO_NOT_FOUND = Ausgangspunkt und Fahrtziel unbekannt. Können Sie bitte ein Wenig detailierter beschreiben? -TOO_CLOSE = Abstand zwischen Ausgangspunkt und Fahrtziel zu gering. -GEOCODE_FROM_AMBIGUOUS = Der Trip-Planner kann den Ausgangspunkt nicht genau erkennen. Bitte wählen sie aus den folgenden Optionen aus oder geben Sie mehr Details an. -GEOCODE_TO_AMBIGUOUS = Der Trip-Planner kann das Fahrtziel nicht genau erkennen. Bitte wählen sie aus den folgenden Optionen aus oder geben Sie mehr Details an. -GEOCODE_FROM_TO_AMBIGUOUS = Ausgangspunkt und Fahrtziel konnten nicht erkannt werden. Bitte wählen sie aus den folgenden Optionen aus oder geben Sie mehr Details an. - -UNDERSPECIFIED_TRIANGLE = Wenn einer der Parameter triangleSafetyFactor, triangleSlopeFactor und triangleTimeFactor gesetzt ist müssen alle bestimmt sein. -TRIANGLE_NOT_AFFINE = Die Summe von triangleSafetyFactor, triangleSlopeFactor, und triangleTimeFactor muss 1 betragen. -TRIANGLE_OPTIMIZE_TYPE_NOT_SET = Wenn triangleSafetyFactor, triangleSlopeFactor und triangleTimeFactor gesetzt sind, dann muss OptimizeType gleich TRIANGLE sein. -TRIANGLE_VALUES_NOT_SET = Wenn OptimizeType gleich TRIANGLE ist, müssen triangleSafetyFactor, triangleSlopeFactor und triangleTimeFactor gesetzt sein. diff --git a/src/test/resources/Message_es.properties b/src/test/resources/Message_es.properties deleted file mode 100644 index 1b11252f87c..00000000000 --- a/src/test/resources/Message_es.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Strings used by the Messages.java enum (i.e., if that enum's name changes, the properties files' names must change) -# - -# PLANNER ERROR MESSAGES -PLAN_OK = ES-Success -SYSTEM_ERROR = ES-We're sorry. The trip planner is temporarily unavailable. Please try again later. - -OUTSIDE_BOUNDS = ES-los trip is not possible. You might be trying to plan a trip outside the map data boundary. -REQUEST_TIMEOUT = ES-los trip planner is taking way too long to process your request. Please try again later. -BOGUS_PARAMETER = ES-los request has errors that the server is not willing or able to process. -PATH_NOT_FOUND = ES-los trip is not possible. Please check that you plan is within the bound of the map. -NO_TRANSIT_TIMES = ES-Non transit times available. The date may be past or too far in the future or there may not be transit service for your trip at the time you chose. -GEOCODE_FROM_NOT_FOUND = ES-los Origin is unknown. Can you be a bit more descriptive? -GEOCODE_TO_NOT_FOUND = ES-los Destination is unknown. Can you be a bit more descriptive? -GEOCODE_FROM_TO_NOT_FOUND = ES-Dos origin and destination are unknown. Can you be a bit more descriptive? -TOO_CLOSE = ES-los Origin is within a trivial distance of the destination. - -GEOCODE_FROM_AMBIGUOUS = ES-los trip planner is unsure of the location you want to start from. Please select from the following options, or be more specific. -GEOCODE_TO_AMBIGUOUS = ES-los trip planner is unsure of the destination you want to go to. Please select from the following options, or be more specific. -GEOCODE_FROM_TO_AMBIGUOUS = ES-Dos origin and destination are ambiguous. Please select from the following options, or be more specific. \ No newline at end of file diff --git a/src/test/resources/Message_fr.properties b/src/test/resources/Message_fr.properties deleted file mode 100644 index f22b3a05418..00000000000 --- a/src/test/resources/Message_fr.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Strings used by the Messages.java enum (i.e., if that enum's name changes, the properties files' names must change) -# - -# PLANNER ERROR MESSAGES -PLAN_OK = FR-Effectué -SYSTEM_ERROR = FR-Nous sommes désolés. Le planificateur de voyage est temporairement indisponible. Merci de réessayer plus tard. - -OUTSIDE_BOUNDS = FR-L\'itinéraire demandé n\'est pas possible. Vous essayez probablement de planifier un itinéraire en dehors de la zone disponible. -REQUEST_TIMEOUT = FR-Le planificateur d\'itinéraires met bien trop de temps à étudier votre demande. Merci de réessayer plus tard. -BOGUS_PARAMETER = FR-La requête renvoie des erreurs que le serveur ne veut ou ne peut étudier. -PATH_NOT_FOUND = FR-L\'itinéraire demandé n'est pas possible. Merci de vérifier que votre itinéraire se situe bien dans les limites de la carte. -NO_TRANSIT_TIMES = FR-Aucun horaire de voyage disponible. La date est peut-être passée où trop loin dans le futur, ou il n'y a pas de service de transports sur votre trajet à l\'heure demandée. -GEOCODE_FROM_NOT_FOUND = FR-L\'origine est inconnue. Pouvez-vous être plus précis ? -GEOCODE_TO_NOT_FOUND = FR-La destination est inconnue. Pouvez-vous être plus précis ? -GEOCODE_FROM_TO_NOT_FOUND = FR-Ni l\'origine ni la destination ne sont connues. Pouvez-vous être plus précis ? -TOO_CLOSE = FR-L\'origine est trop proche de la destination. - -GEOCODE_FROM_AMBIGUOUS = FR-Le planificateur de voyage n'est pas sûr du lieu d\'où vous voulez partir. Merci de le sélectionner parmi les options suivantes ou d\'être plus précis. -GEOCODE_TO_AMBIGUOUS = FR-Le planificateur de voyage n'est pas sûr du lieu où vous voulez aller. Merci de le sélectionner parmi les options suivantes, ou d\'être plus précis. -GEOCODE_FROM_TO_AMBIGUOUS = FR-L\'origine et la destination sont toutes deux ambigües. Merci de les sélectionner parmi les options suivantes, où d\'être plus précis. diff --git a/test/ci-performance-test/travelSearch-expected-results.csv b/test/ci-performance-test/travelSearch-expected-results.csv index b36c2e27735..7ab5b5bc0ac 100644 --- a/test/ci-performance-test/travelSearch-expected-results.csv +++ b/test/ci-performance-test/travelSearch-expected-results.csv @@ -25,7 +25,7 @@ tcId,transfers,duration,cost,walkDistance,startTime,endTime,modes,agencies,route 4,3,02:35:04,12317,2,16:29:56,19:05:00,RAIL BUS,Vy Vy Buss ØstKol,305 630 R20 VY6,Walk 4s ~ 88863 ~ BUS 305 16:30 16:43 ~ 75832 ~ BUS 630 16:46 16:57 ~ 75527 ~ Walk 4m32s ~ 13916 ~ RAIL R20 17:04 17:37 ~ 13591 ~ Walk 7m ~ 61167 ~ BUS VY6 18:31 19:05 ~ 62212 ~ Walk 0s 4,2,03:30:04,14411,3,16:29:56,20:00:00,BUS,Vy Buss ØstKol,305 630 VY6,Walk 4s ~ 88863 ~ BUS 305 16:30 17:05 ~ 75540 ~ BUS 630 18:05 18:53 ~ 76994 ~ Walk 2s ~ 76995 ~ BUS VY6 19:25 20:00 ~ 62212 ~ Walk 0s 7,2,01:08:46,6070,44,17:04:20,18:13:06,TRAM BUS,RUT,81 11 56,Walk 40s ~ 16131 ~ BUS 81 17:05 17:29 ~ 14896 ~ Walk 2m16s ~ 14616 ~ TRAM 11 17:36 17:56 ~ 575 ~ Walk 6s ~ 89865 ~ BUS 56 18:00 18:13 ~ 22231 ~ Walk 6s -7,3,01:03:46,6583,43,17:24:20,18:28:06,TRAM RAIL BUS,RUT Vy,81 L2 12 56,Walk 40s ~ 16131 ~ BUS 81 17:25 17:30 ~ 16061 ~ Walk 2m8s ~ 15793 ~ RAIL L2 17:35 17:45 ~ 15294 ~ Walk 4m33s ~ 14698 ~ TRAM 12 17:52 18:10 ~ 575 ~ Walk 6s ~ 89865 ~ BUS 56 18:15 18:28 ~ 22231 ~ Walk 6s +7,3,01:03:46,6585,43,17:24:20,18:28:06,TRAM RAIL BUS,RUT Vy,81 L2 12 56,Walk 40s ~ 16131 ~ BUS 81 17:25 17:30 ~ 16061 ~ Walk 2m6s ~ 15793 ~ RAIL L2 17:35 17:45 ~ 15294 ~ Walk 4m33s ~ 14698 ~ TRAM 12 17:52 18:10 ~ 575 ~ Walk 6s ~ 89865 ~ BUS 56 18:15 18:28 ~ 22231 ~ Walk 6s 7,2,01:13:46,6387,44,17:14:20,18:28:06,BUS,RUT,81 30 56,Walk 40s ~ 16131 ~ BUS 81 17:15 17:39 ~ 14896 ~ Walk 1m29s ~ 14894 ~ BUS 30 17:43 18:08 ~ 727 ~ Walk 1m8s ~ 730 ~ BUS 56 18:12 18:28 ~ 22231 ~ Walk 6s 7,2,01:08:46,6070,44,17:34:20,18:43:06,TRAM BUS,RUT,81 11 56,Walk 40s ~ 16131 ~ BUS 81 17:35 17:59 ~ 14896 ~ Walk 2m16s ~ 14616 ~ TRAM 11 18:06 18:26 ~ 575 ~ Walk 6s ~ 89865 ~ BUS 56 18:30 18:43 ~ 22231 ~ Walk 6s 7,1,01:43:34,10919,3273,17:04:20,18:47:54,RAIL BUS,RUT Vy,81 L3,Walk 40s ~ 16131 ~ BUS 81 17:05 17:27 ~ 14861 ~ Walk 5m ~ 15316 ~ RAIL L3 17:42 17:54 ~ 8360 ~ Walk 53m54s