当前位置: 首页>>代码示例>>Java>>正文


Java BBox类代码示例

本文整理汇总了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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:30,代码来源:TmcSegmentsCollection.java

示例2: getBounds

import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public BBox getBounds() {
	return mGraphHopper.getGraphHopperStorage().getBounds();
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:4,代码来源:RoutingProfile.java

示例3: getBBox

import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public BBox getBBox()
{
	return _bbox;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:5,代码来源:RouteSummary.java

示例4: setBBox

import com.graphhopper.util.shapes.BBox; //导入依赖的package包/类
public void setBBox(BBox bbox)
{
	_bbox = bbox;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:5,代码来源:RouteSummary.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:62,代码来源:JsonRoutingResponseWriter.java

示例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);
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:43,代码来源:JsonOptimizationRequestProcessor.java

示例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;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:62,代码来源:JsonMapMatchingResponseWriter.java


注:本文中的com.graphhopper.util.shapes.BBox类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。