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


Java SpatialReference类代码示例

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


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

示例1: constructBuffer

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

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
protected void initLayer() {
    if (getID() == 0L) {
        nativeHandle = create();
        changeStatus(com.esri.android.map.event.OnStatusChangedListener.STATUS
                .fromInt(-1000));
    } else {
        this.setDefaultSpatialReference(SpatialReference.create(layerInfo
                .getSrid()));
        this.setFullExtent(new Envelope(layerInfo.getxMin(), layerInfo
                .getyMin(), layerInfo.getxMax(), layerInfo.getyMax()));
        this.setTileInfo(new TileInfo(layerInfo.getOrigin(), layerInfo
                .getScales(), layerInfo.getResolutions(), layerInfo
                .getScales().length, layerInfo.getDpi(), layerInfo
                .getTileWidth(), layerInfo.getTileHeight()));
        super.initLayer();
    }
}
 
开发者ID:wshunli,项目名称:arcgis-android-tianditu,代码行数:18,代码来源:TianDiTuLayer.java

示例3: constructEllipse

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

示例4: validate

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
@Override
public synchronized void validate() throws ValidationException
{
	LOG.info("validate starts.................");

	super.validate();
	try
	{
		//srIn = SpatialReference.create(inwkid);
		srBuffer = SpatialReference.create(procwkid);
		srOut = SpatialReference.create(outwkid);
	}
	catch(Exception e)
	{
		ValidationException ve = new ValidationException("Invalid wkid");
		LOG.error(e.getMessage());
		LOG.error(ve.getMessage());
		throw ve;
	}
	
	LOG.info("validate ends................");

}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:24,代码来源:VisibilityProcessor.java

示例5: process

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
@Override
public GeoEvent process(GeoEvent ge) throws Exception {
	// Operation phase...
	if (radius == null) {
		radius = (Double) ge.getField(bufferEventFld);
		if (radius == null) {
			Exception e = new Exception("Radius is not defined in geoevent");
			throw (e);
		}
	}
	MapGeometry mapGeo = ge.getGeometry();
	Point eventGeo = (Point) mapGeo.getGeometry();
	double x = eventGeo.getX();
	double y = eventGeo.getY();
	int inwkid = mapGeo.getSpatialReference().getID();
	//int inwkid = eventGeo.getSpatialReference().getWkid();
	Geometry buffer = constructBuffer(x, y, radius,
			units, inwkid, bufferwkid, outwkid);
	
	SpatialReference srOut = SpatialReference.create(outwkid);
	MapGeometry outMapGeo = new MapGeometry(buffer, srOut);
	ge.setGeometry(outMapGeo);
	return ge;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:25,代码来源:BufferProcessor.java

示例6: constructBuffer

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
private Geometry constructBuffer(double x, double y,
		double radius, String units, 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();
	String c_name = uc.findConnonicalName(units);
	int unitout = uc.findWkid(c_name);
	Unit u = LinearUnit.create(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 bufferout;

}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:23,代码来源:BufferProcessor.java

示例7: displaySpotReport

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
@Override
protected Integer displaySpotReport(double x, double y, final int wkid, Integer graphicId, Geomessage geomessage) {
    try {
        Geometry pt = new Point(x, y);
        if (null != mapController.getSpatialReference() && wkid != mapController.getSpatialReference().getID()) {
            pt = GeometryEngine.project(pt, SpatialReference.create(wkid), mapController.getSpatialReference());
        }
        if (null != graphicId) {
            spotReportLayer.updateGraphic(graphicId, pt);
            spotReportLayer.updateGraphic(graphicId, geomessage.getProperties());
        } else {
            Graphic graphic = new Graphic(pt, spotReportSymbol, geomessage.getProperties());
            graphicId = spotReportLayer.addGraphic(graphic);
            
        }
        return graphicId;
    } catch (NumberFormatException nfe) {
        Logger.getLogger(getClass().getName()).log(Level.SEVERE, "Could not parse spot report", nfe);
        return null;
    }
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:22,代码来源:AdvancedSymbolController.java

示例8: showPoint

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
/**
 * Tells the controller to display the given point.
 * @param pt the point to display.
 * @param sr the spatial reference of the point to display.
 */
public void showPoint(Point pt, SpatialReference sr) {
    synchronized (graphicUpdateLock) {
        lastPointShownLatLon = (Point) GeometryEngine.project(pt, sr, Utilities.WGS84);
        if (-1 == pointGraphicId) {
            createPointGraphic(pt);
            createTextGraphics(pt);
        } else {
            updateGraphic(pointGraphicId, pt);
            updateTextGraphics(pt);
            updateTextGraphics(getDistanceBearingString(currentGpsPointLatLon, lastPointShownLatLon));
        }
    }
    
    setLayerVisibility(true);
    moveLayerToTop();
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:22,代码来源:MgrsLayerController.java

示例9: runAfterMapInitialized

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
private void runAfterMapInitialized(DbWebmap webmap) {
    ldm = mMapView.getLocationDisplayManager();
    ldm.start();
    
    identifyListener = new IdentifyListener(mMapView, userCredentials);
    mMapView.setOnSingleTapListener(identifyListener);
    
    mMapView.setOnStatusChangedListener(null);
    
    if (null != webmap && null != webmap.getInitExtent()) {
        mMapView.setExtent(GeometryEngine.project(
                webmap.getInitExtent(),
                SpatialReference.create(SpatialReference.WKID_WGS84),
                mMapView.getSpatialReference()));
    }
}
 
开发者ID:garys-esri,项目名称:offline-mapper-android,代码行数:17,代码来源:MapActivity.java

示例10: doInBackground

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
/**
 * First member in string array is the query URL; second member is the
 * where clause.
 */
@Override
protected FeatureResult doInBackground(String... queryArray) {

    if (queryArray == null || queryArray.length <= 1)
        return null;

    String url = queryArray[0];
    QueryParameters qParameters = new QueryParameters();
    String whereClause = queryArray[1];
    SpatialReference sr = SpatialReference.create(102100);
    // qParameters.setGeometry(mMapView.getExtent());
    qParameters.setOutSpatialReference(sr);
    qParameters.setReturnGeometry(true);
    qParameters.setWhere(whereClause);

    QueryTask qTask = new QueryTask(url);

    try {
        FeatureResult results = qTask.execute(qParameters);
        return results;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:skylight1,项目名称:VR-Map-Explorer,代码行数:30,代码来源:MainActivity.java

示例11: testPolygon

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

示例12: testExclusion

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

示例13: setFence

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

示例14: bufferLine

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

示例15: queryFeatures

import com.esri.core.geometry.SpatialReference; //导入依赖的package包/类
private void queryFeatures(){
	TriggerLayer triggerLayer = (TriggerLayer) layerComboBox.getSelectedItem();
	ArcGISFeatureLayer featureLayer = triggerLayer.getFeatureLayer();
	String where = whereTextField.getText();
	if(Util.isEmpty(where)){
		where = "1=1";
	}
	
	Query query = new Query();
	query.setOutFields(new String[] {"*"});
	query.setOutSpatialReference(SpatialReference.create(SpatialReference.WKID_WGS84));
	query.setWhere(where);
	featureLayer.queryFeatures(query, new CallbackListener<FeatureSet>() {
		
		@Override
		public void onCallback(FeatureSet featureSet) {
			createTrigger(featureSet);
		}
		
		@Override
		public void onError(Throwable e) {
			System.out.println("Error: "+e.getMessage());
		}
	});
}
 
开发者ID:EsriDE,项目名称:PTM-OSMGeotrigger,代码行数:26,代码来源:CreateMultipleTriggersTool.java


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