From 265916f7272310e870e621762bf5ed735cd7ac3d Mon Sep 17 00:00:00 2001 From: Hannes Junnila Date: Thu, 22 Jan 2015 15:42:42 +0200 Subject: [PATCH] Use shorter parameter names in the geocoder --- .../opentripplanner/common/LuceneIndex.java | 22 +++++++++---------- .../index/GeocoderResource.java | 18 +++++++-------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/opentripplanner/common/LuceneIndex.java b/src/main/java/org/opentripplanner/common/LuceneIndex.java index fe20d61f2a4..1bd5f7939a9 100644 --- a/src/main/java/org/opentripplanner/common/LuceneIndex.java +++ b/src/main/java/org/opentripplanner/common/LuceneIndex.java @@ -152,20 +152,20 @@ public void run() { /** Fetch results for the geocoder using the OTP graph for stops, clusters and street names * * @param queryString - * @param autoComplete Whether we should use the query string to do a prefix match - * @param showStops Search for stops, either for name or stop code - * @param showClusters Search for clusters by their name - * @param showCorners Search for street corners using at least one of the street names + * @param autocomplete Whether we should use the query string to do a prefix match + * @param stops Search for stops, either by name or stop code + * @param clusters Search for clusters by their name + * @param corners Search for street corners using at least one of the street names * @return list of results in in the format expected by GeocoderBuiltin.js in the OTP Leaflet client */ - public List query (String queryString, boolean autoComplete, - boolean showStops, boolean showClusters, boolean showCorners) { + public List query (String queryString, boolean autocomplete, + boolean stops, boolean clusters, boolean corners) { /* Turn the query string into a Lucene query.*/ BooleanQuery query = new BooleanQuery(); BooleanQuery termQuery = new BooleanQuery(); for (String term : queryString.split(" ")) { /* PrefixQuery matches all strings that start with the query string */ - if (autoComplete) { + if (autocomplete) { termQuery.add(new PrefixQuery(new Term("name", term)), BooleanClause.Occur.SHOULD); /* FuzzyQuery matches with all string stat are maximum 2 edits away from the query sring */ } else { @@ -177,15 +177,15 @@ public List query (String queryString, boolean autoComplete, } query.add(termQuery, BooleanClause.Occur.MUST); - if (showStops || showClusters || showCorners) { + if (stops || clusters || corners) { BooleanQuery typeQuery = new BooleanQuery(); - if (showStops) { + if (stops) { typeQuery.add(new TermQuery(new Term("category", Category.STOP.name())), BooleanClause.Occur.SHOULD); } - if (showClusters) { + if (clusters) { typeQuery.add(new TermQuery(new Term("category", Category.CLUSTER.name())), BooleanClause.Occur.SHOULD); } - if (showCorners) { + if (corners) { typeQuery.add(new TermQuery(new Term("category", Category.CORNER.name())), BooleanClause.Occur.SHOULD); } query.add(typeQuery, BooleanClause.Occur.MUST); diff --git a/src/main/java/org/opentripplanner/index/GeocoderResource.java b/src/main/java/org/opentripplanner/index/GeocoderResource.java index 4708e907192..cec28d79edc 100644 --- a/src/main/java/org/opentripplanner/index/GeocoderResource.java +++ b/src/main/java/org/opentripplanner/index/GeocoderResource.java @@ -41,20 +41,20 @@ public GeocoderResource (@Context OTPServer otpServer, @PathParam("routerId") St * Geocode using data using the OTP graph for stops, clusters and street names * * @param query The query string we want to geocode - * @param autoComplete Whether we should use the query string to do a prefix match - * @param showStops Search for stops, either for name or stop code - * @param showClusters Search for clusters by their name - * @param showCorners Search for street corners using at least one of the street names + * @param autocomplete Whether we should use the query string to do a prefix match + * @param stops Search for stops, either by name or stop code + * @param clusters Search for clusters by their name + * @param corners Search for street corners using at least one of the street names * @return list of results in in the format expected by GeocoderBuiltin.js in the OTP Leaflet client */ @GET public Response textSearch (@QueryParam("query") String query, - @QueryParam("autoComplete") @DefaultValue("false") boolean autoComplete, - @QueryParam("showStops") @DefaultValue("true") boolean showStops, - @QueryParam("showClusters") @DefaultValue("false") boolean showClusters, - @QueryParam("showCorners") @DefaultValue("true") boolean showCorners + @QueryParam("autocomplete") @DefaultValue("false") boolean autocomplete, + @QueryParam("stops") @DefaultValue("true") boolean stops, + @QueryParam("clusters") @DefaultValue("false") boolean clusters, + @QueryParam("corners") @DefaultValue("true") boolean corners ) { - return Response.status(Response.Status.OK).entity(index.query(query, autoComplete, showStops, showClusters, showCorners)).build(); + return Response.status(Response.Status.OK).entity(index.query(query, autocomplete, stops, clusters, corners)).build(); } }