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


Java Polygon类代码示例

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


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

示例1: _parseGeometryType

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
private static String _parseGeometryType(GeometryType t)
{
	String type = null;
	if(t == GeometryType.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==GeometryType.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==GeometryType.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==GeometryType.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:22,代码来源:GeometryUtility.java

示例2: GenerateEllipse

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
public Polygon GenerateEllipse(Point center, double majorAxis, double minorAxis, double ra)
{
	Polygon ellipse = new Polygon();
	for (int i = 0; i < 360; ++i)
	{
		double theta = Math.toRadians(i);
		Point p = ellipsePtFromAngle(center, majorAxis, minorAxis, theta);
		p = GeometryUtility.Rotate(center, p, ra);
		if (i == 0) {
			ellipse.startPath(p);
		}
		else{
			ellipse.lineTo(p);
		}
	}
	ellipse.closeAllPaths();
	return ellipse;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:19,代码来源:GeometryUtility.java

示例3: _parseGeometryType

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
private static String _parseGeometryType(Geometry.Type t)
{
	String type = null;
	if(t == Geometry.Type.Point)
	{
		type = "esriGeometryPoint";
	}
	else if (t==Geometry.Type.Polyline)
	{
		type = "esriGeometryPolyline";
	}
	else if (t==Geometry.Type.Polygon)
	{
		type = "esriGeometryPolygon";
	}
	else if (t==Geometry.Type.MultiPoint)
	{
		type = "esriGeometryMultiPoint";
	}
	return type;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:22,代码来源:GeometryUtility.java

示例4: constructEllipse

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
private MapGeometry constructEllipse(double x, double y, double majorAxis, double minorAxis, double rotation, int wkidin, int wkidbuffer, int wkidout)
{
	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();
	majorAxis = uc.Convert(majorAxis, units, srBuffer);
	minorAxis = uc.Convert(minorAxis, units, srBuffer);
	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);
	MapGeometry mapGeo = new MapGeometry(ellipseOut, srOut);
	return mapGeo;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:19,代码来源:EllipseProcessor.java

示例5: test1

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
@Test
public void test1() throws Exception {

	int cpt = 0;
	for (int i = 1; i < MAX; i++) {
		ArrayList<MultiPathAndRole> a = loadElements(i);
		int size = a.size();
		// System.out.println("evaluate " + i + " nb elements :" +
		// ret.length);
		try {
			Polygon polygon = PolygonCreator.createPolygon(a, new IInvalidPolygonConstructionFeedBack() {

				@Override
				public void polygonCreationFeedBackReport(List<MultiPathAndRole> elements, String reason)
						throws Exception {

				}
			});
			System.out.println(
					"" + i + " OK -> " + (cpt++) + " nb parts :" + size + " nbpoints :" + polygon.getPointCount());
		} catch (Exception e) {

		}
	}
}
 
开发者ID:frett27,项目名称:osm-flink-tools,代码行数:26,代码来源:TestIsolateBadPolygons.java

示例6: testPolygon

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
@Test
public void testPolygon() throws IOException, JSONException {
    Properties properties = new Properties();
    properties.load(new FileInputStream("config/oberbayern.properties"));
    RoadReader reader = Loader.reader(properties);
    Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt(
            "POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))",
            WktImportFlags.wktImportDefaults, Type.Polygon);
    BaseRoad road = null;

    reader.open(polygon, null);
    int count = 0;

    while ((road = reader.next()) != null) {
        assertTrue(
                GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326))
                        || GeometryEngine.contains(polygon, road.geometry(),
                                SpatialReference.create(4326)));
        count += 1;
    }

    reader.close();
    assertTrue(count > 0);
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:25,代码来源:PostGISReaderTest.java

示例7: testExclusion

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
@Test
public void testExclusion() throws IOException, JSONException {
    Properties properties = new Properties();
    properties.load(new FileInputStream("config/oberbayern.properties"));
    RoadReader reader = Loader.reader(properties);
    Polygon polygon = (Polygon) GeometryEngine.geometryFromWkt(
            "POLYGON ((11.40848 47.93157, 11.45109 47.93157,11.45109 47.89296,11.40848 47.89296,11.40848 47.93157))",
            WktImportFlags.wktImportDefaults, Type.Polygon);
    HashSet<Short> exclusion = new HashSet<>(Arrays.asList((short) 117));
    BaseRoad road = null;

    reader.open(polygon, exclusion);
    int count = 0;

    while ((road = reader.next()) != null) {
        assertTrue(
                GeometryEngine.overlaps(polygon, road.geometry(), SpatialReference.create(4326))
                        || GeometryEngine.contains(polygon, road.geometry(),
                                SpatialReference.create(4326)));
        assertTrue(!exclusion.contains(road.type()));
        count += 1;
    }

    reader.close();
    assertTrue(count > 0);
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:27,代码来源:PostGISReaderTest.java

示例8: type

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:GeoFunctions.java

示例9: setFence

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
public static void setFence(Polygon newFence, SpatialReference fenceSpatialReference) {

    // Keep the original geometries.
    mFenceSr = fenceSpatialReference;
    mFence = newFence;

    // Work with the fence in WGS84, as that's what the location updates will be in.
    // Note that transformations could be used here to increase accuracy.
    if ( mFenceSr.getID() != mWgs84Sr.getID() ) {
      Geometry densified = GeometryEngine.geodesicDensifyGeometry(mFence,
          mFenceSr, 20, null);
      mFenceWgs84 = (Polygon)GeometryEngine.project(densified, mFenceSr, mWgs84Sr);
    }
    else {
      mFenceWgs84 = mFence;
    }
  }
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:18,代码来源:LocalGeofence.java

示例10: onActivityResult

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  // Receive results from either map or list geofence selection - both give
  // exactly the same information.
  if (data == null) return;

  if (resultCode == RESULT_OK) {

    long fenceOid = data.getLongExtra(GEOFENCE_FEATURE_OBJECTID_EXTRA_ID, -1);
    Feature fenceFeature = getFeatureFromGeodatabase(fenceOid);
    if (fenceFeature != null) {
      Polygon fencePolygon = (Polygon)fenceFeature.getGeometry();
      String fenceName = fenceFeature.getAttributeValue(FENCE_NAME_FIELD).toString();
      LocalGeofence.setFence(fencePolygon, mGdbFeatureTable.getSpatialReference());
      LocalGeofence.setFeatureName(fenceName);
      LocalGeofence.setFeatureOid(fenceOid);

      mFenceNameTextView.setText(fenceName);
    }
  }
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:22,代码来源:MainActivity.java

示例11: bufferLine

import com.esri.core.geometry.Polygon; //导入依赖的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

示例12: testGeomFromPolygonShape

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
@Test
public void testGeomFromPolygonShape() throws UDFArgumentException {
	Polygon polygon = createPolygon();
	byte[] esriShape = GeometryEngine.geometryToEsriShape(polygon);
	assertNotNull("The shape must not be null!", esriShape);

	BytesWritable shapeAsWritable = new BytesWritable(esriShape);
	assertNotNull("The shape writable must not be null!", shapeAsWritable);

	final int wkid = 4326;
	ST_GeomFromShape fromShape = new ST_GeomFromShape();
	BytesWritable geometryAsWritable = fromShape.evaluate(shapeAsWritable, wkid);
	assertNotNull("The geometry writable must not be null!", geometryAsWritable);

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryAsWritable);
	assertNotNull("The OGC geometry must not be null!", ogcGeometry);

	Geometry esriGeometry = ogcGeometry.getEsriGeometry();
	assertNotNull("The Esri geometry must not be null!", esriGeometry);
	assertTrue("The geometries are different!",
			GeometryEngine.equals(polygon, esriGeometry, SpatialReference.create(wkid)));
}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:23,代码来源:TestStGeomFromShape.java

示例13: parseSimplePolygonCoordinates

import com.esri.core.geometry.Polygon; //导入依赖的package包/类
/**
 * Example:
 * [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
 * @param parser
 * @return a polygon
 * @throws JsonParseException
 * @throws IOException
 */
private Polygon parseSimplePolygonCoordinates(JsonNode node) {
  Polygon g = new Polygon();
  boolean first = true;
  ArrayNode points = (ArrayNode) node;
  for (JsonNode point : points) {
    Point p = parsePointCoordinates(point);
    if (first) {
      g.startPath(p);
      first = false;
    } else {
      g.lineTo(p);
    }  
  }
  g.closeAllPaths();
  return g;
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demo-java,代码行数:25,代码来源:GeoJsonParser.java


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