本文整理汇总了Java中com.graphhopper.util.shapes.BBox类的典型用法代码示例。如果您正苦于以下问题:Java BBox类的具体用法?Java BBox怎么用?Java BBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BBox类属于com.graphhopper.util.shapes包,在下文中一共展示了BBox类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClosestSegment
import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public TmcSegment getClosestSegment(Coordinate c, double thresholdDistance)
{
if (quadTree == null)
buildQuadTree();
Point p = geomFactory.createPoint(c);
BBox bbox = distanceCalc.createBBox(c.y, c.x, thresholdDistance);
Envelope env = new Envelope(bbox.minLon, bbox.maxLon, bbox.minLat, bbox.maxLat);
@SuppressWarnings("unchecked")
List<TmcSegment> segments = (List<TmcSegment>)(quadTree.query(env));
double minDistance = Double.MAX_VALUE;
TmcSegment res = null;
for( TmcSegment seg : segments)
{
Coordinate c1 = DistanceOp.nearestPoints(seg.getGeometry(), p)[0];
double dist = distanceCalc.calcDist(c.y, c.x, c1.y, c1.x);
if (dist < minDistance)
{
minDistance = dist;
if (dist <= thresholdDistance)
res = seg;
}
}
return res;
}
示例2: getBounds
import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public BBox getBounds() {
return mGraphHopper.getGraphHopperStorage().getBounds();
}
示例3: getBBox
import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public BBox getBBox()
{
return _bbox;
}
示例4: setBBox
import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public void setBBox(BBox bbox)
{
_bbox = bbox;
}
示例5: toJson
import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public static JSONObject toJson(RoutingRequest request, RouteResult[] routeResult) throws Exception
{
JSONObject jResp = new JSONObject(true, 1);
BBox bbox = new BBox(0, 0, 0, 0);
JSONArray jRoutes = toJsonArray(request, routeResult, bbox);
jResp.put("routes", jRoutes);
// *************** bbox ***************
if (bbox != null)
jResp.put("bbox", GeometryJSON.toJSON(bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat));
// *************** info ***************
JSONObject jInfo = new JSONObject(3);
jInfo.put("service", "routing");
jInfo.put("engine", AppInfo.getEngineInfo());
if (!Helper.isEmpty(RoutingServiceSettings.getAttribution()))
jInfo.put("attribution", RoutingServiceSettings.getAttribution());
jInfo.put("timestamp", System.currentTimeMillis());
JSONObject jQuery = new JSONObject(true);
jQuery.put("profile", RoutingProfileType.getName(request.getSearchParameters().getProfileType()));
jQuery.put("preference", WeightingMethod.getName(request.getSearchParameters().getWeightingMethod()));
jQuery.put("coordinates", GeometryJSON.toJSON(request.getCoordinates(), request.getIncludeElevation()));
if (request.getLanguage() != null)
jQuery.put("language", request.getLanguage());
if (request.getUnits() != null)
jQuery.put("units", DistanceUnitUtil.toString(request.getUnits()));
jQuery.put("geometry", request.getIncludeGeometry());
if (request.getIncludeGeometry())
{
jQuery.put("geometry_format", Helper.isEmpty(request.getGeometryFormat()) ? "encodedpolyline" : request.getGeometryFormat());
jQuery.put("geometry_simplify", request.getSimplifyGeometry());
if (request.getIncludeInstructions())
jQuery.put("instructions_format", request.getInstructionsFormat().toString().toLowerCase());
jQuery.put("instructions", request.getIncludeInstructions());
jQuery.put("elevation", request.getIncludeElevation());
}
if (!Helper.isEmpty(request.getSearchParameters().getOptions()))
jQuery.put("options", new JSONObject(request.getSearchParameters().getOptions()));
if (!Helper.isEmpty(request.getId()))
jQuery.put("id", request.getId());
jInfo.put("query", jQuery);
jResp.put("info", jInfo);
return jResp;
}
示例6: writeResponse
import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
private void writeResponse(HttpServletResponse response, RouteOptimizationRequest request, RouteOptimizationResult optResult) throws Exception
{
JSONObject jResp = new JSONObject(true);
RoutingRequest reqRoute = request.createRoutingRequest(optResult.getWayPoints());
BBox bbox = new BBox(0, 0, 0, 0);
JSONArray jRoutes = JsonRoutingResponseWriter.toJsonArray(reqRoute, new RouteResult[] { optResult.getRouteResult() }, bbox);
jResp.put("routes", jRoutes);
JSONArray jWayPoints = new JSONArray();
jWayPoints.put(0, new JSONArray(optResult.getWayPoints()));
jResp.put("way_points", jWayPoints);
if (bbox != null)
jResp.put("bbox", GeometryJSON.toJSON(bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat));
JSONObject jQuery = new JSONObject();
jQuery.put("profile", RoutingProfileType.getName(request.getProfileType()));
if (request.getUnits() != null)
jQuery.put("units", DistanceUnitUtil.toString(request.getUnits()));
/*if (request.getWeightingMethod() != null)
jQuery.put("preference", request.getWeightingMethod());*/
if (request.getId() != null)
jQuery.put("id", request.getId());
JSONObject jInfo = new JSONObject(true);
jInfo.put("service", "optimization");
jInfo.put("engine", AppInfo.getEngineInfo());
if (!Helper.isEmpty(OptimizationServiceSettings.getAttribution()))
jInfo.put("attribution", OptimizationServiceSettings.getAttribution());
jInfo.put("timestamp", System.currentTimeMillis());
jInfo.put("query", jQuery);
jResp.put("info", jInfo);
ServletUtility.write(response, jResp);
}
示例7: toJson
import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public static JSONObject toJson(RoutingRequest request, RouteResult[] routeResult) throws Exception
{
JSONObject jResp = new JSONObject(true, 1);
BBox bbox = new BBox(0, 0, 0, 0);
JSONArray jRoutes = toJsonArray(request, routeResult, bbox);
jResp.put("routes", jRoutes);
// *************** bbox ***************
if (bbox != null)
jResp.put("bbox", GeometryJSON.toJSON(bbox.minLon, bbox.minLat, bbox.maxLon, bbox.maxLat));
// *************** info ***************
JSONObject jInfo = new JSONObject(3);
jInfo.put("service", "routing");
jInfo.put("engine", AppInfo.getEngineInfo());
if (!Helper.isEmpty(MapMatchingServiceSettings.getAttribution()))
jInfo.put("attribution", RoutingServiceSettings.getAttribution());
jInfo.put("timestamp", System.currentTimeMillis());
JSONObject jQuery = new JSONObject(true);
jQuery.put("profile", RoutingProfileType.getName(request.getSearchParameters().getProfileType()));
jQuery.put("preference", WeightingMethod.getName(request.getSearchParameters().getWeightingMethod()));
jQuery.put("coordinates", GeometryJSON.toJSON(request.getCoordinates(), request.getIncludeElevation()));
if (request.getLanguage() != null)
jQuery.put("language", request.getLanguage());
if (request.getUnits() != null)
jQuery.put("units", DistanceUnitUtil.toString(request.getUnits()));
jQuery.put("geometry", request.getIncludeGeometry());
if (request.getIncludeGeometry())
{
jQuery.put("geometry_format", Helper.isEmpty(request.getGeometryFormat()) ? "encodedpolyline" : request.getGeometryFormat());
jQuery.put("geometry_simplify", request.getSimplifyGeometry());
if (request.getIncludeInstructions())
jQuery.put("instructions_format", request.getInstructionsFormat().toString().toLowerCase());
jQuery.put("instructions", request.getIncludeInstructions());
jQuery.put("elevation", request.getIncludeElevation());
}
if (!Helper.isEmpty(request.getSearchParameters().getOptions()))
jQuery.put("options", new JSONObject(request.getSearchParameters().getOptions()));
if (!Helper.isEmpty(request.getId()))
jQuery.put("id", request.getId());
jInfo.put("query", jQuery);
jResp.put("info", jInfo);
return jResp;
}