本文整理汇总了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);
}
示例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();
}
}
示例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;
}
示例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................");
}
示例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;
}
示例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;
}
示例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;
}
}
示例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();
}
示例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()));
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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());
}
});
}