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


Java GeometryEngine.geometryToJson方法代码示例

本文整理汇总了Java中com.esri.core.geometry.GeometryEngine.geometryToJson方法的典型用法代码示例。如果您正苦于以下问题:Java GeometryEngine.geometryToJson方法的具体用法?Java GeometryEngine.geometryToJson怎么用?Java GeometryEngine.geometryToJson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.esri.core.geometry.GeometryEngine的用法示例。


在下文中一共展示了GeometryEngine.geometryToJson方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructBuffer

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private com.esri.ges.spatial.Geometry constructBuffer(double x, double y, double radius, String units, int wkidin, int wkidbuffer, int wkidout) throws GeometryException
{
	Point center = new Point();
	center.setX(x);
	center.setY(y);
	SpatialReference srIn = SpatialReference.create(wkidin);
	SpatialReference srBuffer = SpatialReference.create(wkidbuffer);
	SpatialReference srOut = SpatialReference.create(wkidout);
	UnitConverter uc = new UnitConverter();
	String c_name = uc.findConnonicalName(units);
	int unitout = uc.findWkid(c_name);
	Unit  u = new LinearUnit(unitout);
	Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer);
	Geometry buffer = GeometryEngine.buffer(centerProj, srBuffer, radius, u);
	Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut);
	String json = GeometryEngine.geometryToJson(srOut, bufferout);
	return spatial.fromJson(json);
	
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:20,代码来源:BufferProcessor.java

示例2: bufferLine

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
/**
 * Create a buffer for a line.
 * @param lineJsonString A JSON string defining the line.
 * @param distance The buffer distance.
 * @return A JSON string with the buffer polygon.
 */
public static String bufferLine(String lineJsonString, double distance){
	String geoJson = null;
	try{
		Polyline polyline = new Polyline();
		JSONObject lineJson = new JSONObject(lineJsonString);
		JSONArray paths = lineJson.getJSONArray("paths");
		JSONArray line = paths.getJSONArray(0);
		for(int k = 0; k < line.length(); k++){
			JSONArray point = line.getJSONArray(k);
			double x = point.getDouble(0);
			double y = point.getDouble(1);
			if(k == 0){
				polyline.startPath(x, y);
			}else{
				polyline.lineTo(x, y);
			}
		}
		SpatialReference srsWGS84 = SpatialReference.create(SpatialReference.WKID_WGS84);
		SpatialReference srsWebMercator = SpatialReference.create(SpatialReference.WKID_WGS84_WEB_MERCATOR);
		Geometry mercatorPolyline = GeometryEngine.project(polyline, srsWGS84, srsWebMercator);
		Polygon mercatorPolygon = GeometryEngine.buffer(mercatorPolyline, srsWebMercator, distance, srsWebMercator.getUnit());
		Polygon polygon = (Polygon) GeometryEngine.project(mercatorPolygon, srsWebMercator, srsWGS84);
		geoJson = GeometryEngine.geometryToJson(srsWGS84, polygon);			
	}catch(Exception e){
		log.error("Error creating line buffer: "+e.getMessage());
	}
	return geoJson;
}
 
开发者ID:EsriDE,项目名称:PTM-OSMGeotrigger,代码行数:35,代码来源:Util.java

示例3: evaluate

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
public Text evaluate(BytesWritable geomref){
	if (geomref == null || geomref.getLength() == 0){
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
	if (ogcGeometry == null){
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}

	Geometry esriGeom = ogcGeometry.getEsriGeometry();
	int wkid = GeometryUtils.getWKID(geomref);
	return new Text(GeometryEngine.geometryToJson(wkid, esriGeom));
}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:17,代码来源:ST_AsJson.java

示例4: constructEllipse

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private com.esri.ges.spatial.Geometry constructEllipse(double x, double y, double majorAxis, double minorAxis, double rotation, int wkidin, int wkidbuffer, int wkidout) throws GeometryException
{
	Point center = new Point();
	center.setX(x);
	center.setY(y);
	SpatialReference srIn = SpatialReference.create(wkidin);
	SpatialReference srBuffer = SpatialReference.create(wkidbuffer);
	SpatialReference srOut = SpatialReference.create(wkidout);
	Point centerProj = (Point) GeometryEngine.project(center, srIn, srBuffer);
	GeometryUtility geoutil = new GeometryUtility();
	Polygon ellipse = geoutil.GenerateEllipse(centerProj, majorAxis, minorAxis, rotation);
	Geometry ellipseOut = GeometryEngine.project(ellipse, srBuffer, srOut);
	String json = GeometryEngine.geometryToJson(srOut, ellipseOut);
	return spatial.fromJson(json);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:16,代码来源:EllipseProcessor.java

示例5: constructGeometryFromString

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private com.esri.ges.spatial.Geometry constructGeometryFromString(String geoString) throws GeometryException
{
	String[] pairs = geoString.split(" ");
	
	Polygon polygon = new Polygon();
	Boolean firstit = true;
	for(String coords: pairs)
	{
		
		String[] tuple = coords.split(",");
		Double x = Double.parseDouble(tuple[0]);
		Double y = Double.parseDouble(tuple[1]);
		Point p = new Point(x,y);
		Double z = Double.NaN;
		if (tuple.length>2)
		{
			z = Double.parseDouble(tuple[2]);
			p.setZ(z);
		}
		if(firstit)
		{
			polygon.startPath(p);
			firstit=false;
		}
		else
		{
			polygon.lineTo(p);
		}
	}
	polygon.closeAllPaths();
	String json = GeometryEngine.geometryToJson(srIn, polygon);
	return spatial.fromJson(json);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:34,代码来源:QueryReportProcessor.java

示例6: constructBuffer

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private com.esri.ges.spatial.Geometry constructBuffer(Geometry geo, double radius, Unit u) throws GeometryException, JsonParseException, IOException
{
	
	com.esri.core.geometry.Geometry buffer = GeometryEngine.buffer(inGeometry, srBuffer, radius, u);
	com.esri.core.geometry.Geometry bufferout = GeometryEngine.project(buffer, srBuffer, srOut);
	String json = GeometryEngine.geometryToJson(srOut, bufferout);
	return spatial.fromJson(json);
	
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:10,代码来源:QueryReportProcessor.java

示例7: constructCAPGeometry

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private com.esri.ges.spatial.Geometry constructCAPGeometry(String geoString)
		throws GeometryException {
	try {
		String[] pairs = geoString.split(" ");

		Polygon polygon = new Polygon();
		Boolean firstit = true;
		for (String coords : pairs) {

			String[] tuple = coords.split(",");
			Double x = Double.parseDouble(tuple[0]);
			Double y = Double.parseDouble(tuple[1]);
			Point p = new Point(x, y);
			Double z = Double.NaN;
			if (tuple.length > 2) {
				z = Double.parseDouble(tuple[2]);
				p.setZ(z);
			}
			if (firstit) {
				polygon.startPath(p);
				firstit = false;
			} else {
				polygon.lineTo(p);
			}
		}
		polygon.closeAllPaths();
		String json = GeometryEngine.geometryToJson(srIn, polygon);
		return spatial.fromJson(json);
	} catch (GeometryException ex) {
		LOG.error(ex.getMessage());
		LOG.error(ex.getStackTrace());
		return null;
	}
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:35,代码来源:PolygonProcessor.java

示例8: ConstructJsonMaskFromGeoEvent

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private String ConstructJsonMaskFromGeoEvent(GeoEvent ge) throws IOException
{
	com.esri.ges.spatial.Geometry eventgeo = ge.getGeometry();
	String json = eventgeo.toJson();
	JsonFactory jf = new JsonFactory();
	JsonParser jp = jf.createJsonParser(json);
	MapGeometry mgeo = GeometryEngine.jsonToGeometry(jp);
	Geometry geo = mgeo.getGeometry();
	Geometry maskGeo = GeometryEngine.project(geo, srIn, srBuffer);
	return GeometryEngine.geometryToJson(srBuffer, maskGeo);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:12,代码来源:VisibilityProcessor.java

示例9: ConstructJsonMaskFromGeoEvent

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private String ConstructJsonMaskFromGeoEvent(GeoEvent ge) throws IOException
{
	MapGeometry eventgeo = ge.getGeometry();
	Geometry geo = eventgeo.getGeometry();
	Geometry maskGeo = GeometryEngine.project(geo, srIn, srBuffer);
	return GeometryEngine.geometryToJson(srBuffer, maskGeo);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:8,代码来源:VisibilityProcessor.java

示例10: createTrigger

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
private void createTrigger(){
	String triggerId = triggerIdTextField.getText();
	String direction = (String) directionComboBox.getSelectedItem();
	String tagStr = tagsTextField.getText();
	String[] tags = tagStr.split(",");
	String notificationText = notificationTextField.getText();
	String notificationUrl = notificationUrlTextField.getText();
	String notificationData = notificationDataTextField.getText();
	String callBackUrl = callbackUrlTextField.getText();
	String properties = propertiesTextField.getText();
	String trackingProfile = (String) trackingProfileComboBox.getSelectedItem();
	if(trackingProfile.contains("-")){
		trackingProfile = "";
	}
	
	TriggerHandler triggerhandler = new TriggerHandler();
	if(triggerType == TRIGGER_TYPE_CIRCLE){
		com.esri.core.geometry.Point wgsCenterPoint = (com.esri.core.geometry.Point)GeometryEngine.project(triggerCenterPoint, map.getSpatialReference(), SpatialReference.create(SpatialReference.WKID_WGS84));
		double latitude = wgsCenterPoint.getY();
		double longitude = wgsCenterPoint.getX();
		triggerhandler.createTrigger(triggerId, tags, direction, latitude, longitude, triggerRadius, notificationText, notificationUrl, null, null, notificationData, callBackUrl, properties, trackingProfile, -1, -1, null, null, -1, -1);									
	}else if(triggerType == TRIGGER_TYPE_POLYGON){
		Geometry wgsPolygon = GeometryEngine.project(triggerPolygon, map.getSpatialReference(), SpatialReference.create(SpatialReference.WKID_WGS84));
		String geoJson = GeometryEngine.geometryToJson(SpatialReference.create(SpatialReference.WKID_WGS84), wgsPolygon);
		System.out.println("geoJson: "+geoJson);
		triggerhandler.createTrigger(triggerId, tags, direction, geoJson, notificationText, notificationUrl, null, null, notificationData, callBackUrl, properties, trackingProfile, -1, -1, null, null, -1, -1);
	}
	JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(map), "Trigger created.");
}
 
开发者ID:EsriDE,项目名称:PTM-OSMGeotrigger,代码行数:30,代码来源:CreateTriggerTool.java

示例11: toJson

import com.esri.core.geometry.GeometryEngine; //导入方法依赖的package包/类
public String toJson(int wkid, com.esri.core.geometry.Geometry geometry) throws GeometryException
{
	return GeometryEngine.geometryToJson(wkid, geometry);
}
 
开发者ID:Esri,项目名称:route-monitor-for-geoevent,代码行数:5,代码来源:GeometryAdapter.java


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