org.opentripplanner.geocoder.reverse.MunicoderServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.geocoder.reverse;
import javax.ws.rs.BadRequestException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
/*import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Envelope;*/
@Path("/municoder")
public class MunicoderServer {
/* FIXME Spring config looked like this:
*/
// FIXME inject context
private BoundaryResolver boundaryResolver;
public void setBoundaryResolver(BoundaryResolver boundaryResolver) {
this.boundaryResolver = boundaryResolver;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public String resolveLocation(
@QueryParam("location") String location,
@QueryParam("callback") String callback) {
if (location == null) {
throw new BadRequestException("no 'location' to resolve");
}
String[] arr = location.split(",");
//System.out.println("br="+boundaryResolver);
//return arr[0];
String result = boundaryResolver.resolve(Double.parseDouble(arr[1]), Double.parseDouble(arr[0]));
result = (result == null) ? "{}" : "{ \"name\" : \""+result+"\" }";
if(callback != null) {
return callback+"("+result+");";
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy