com.esri.core.geometry.SpatialReference Java Examples
The following examples show how to use
com.esri.core.geometry.SpatialReference.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_MPolyFromWKB.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException { try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } byte [] byteArr = wkb.getBytes(); ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length); byteBuf.put(byteArr); OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf); ogcObj.setSpatialReference(spatialReference); String gType = ogcObj.geometryType(); if (gType.equals("MultiPolygon") || gType.equals("Polygon")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTIPOLYGON, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LOG.error(e.getMessage()); return null; } }
Example #2
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_PolyFromWKB.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException { try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } byte [] byteArr = wkb.getBytes(); ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length); byteBuf.put(byteArr); OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf); ogcObj.setSpatialReference(spatialReference); if (ogcObj.geometryType().equals("Polygon")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POLYGON, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LOG.error(e.getMessage()); return null; } }
Example #3
Source Project: arcgis-android-moremap Author: wshunli File: MoreMapLayer.java License: Apache License 2.0 | 6 votes |
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(); } }
Example #4
Source Project: defense-solutions-proofs-of-concept Author: Esri File: BufferProcessor.java License: Apache License 2.0 | 6 votes |
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); }
Example #5
Source Project: defense-solutions-proofs-of-concept Author: Esri File: EllipseProcessor.java License: Apache License 2.0 | 6 votes |
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; }
Example #6
Source Project: defense-solutions-proofs-of-concept Author: Esri File: BufferProcessor.java License: Apache License 2.0 | 6 votes |
@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; }
Example #7
Source Project: defense-solutions-proofs-of-concept Author: Esri File: BufferProcessor.java License: Apache License 2.0 | 6 votes |
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; }
Example #8
Source Project: defense-solutions-proofs-of-concept Author: Esri File: AdvancedSymbolController.java License: Apache License 2.0 | 6 votes |
@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; } }
Example #9
Source Project: geometry-api-java Author: Esri File: OGCGeometry.java License: Apache License 2.0 | 6 votes |
public static OGCGeometry createFromEsriCursor(GeometryCursor gc, SpatialReference sr, boolean skipEmpty) { ArrayList<OGCGeometry> geoms = new ArrayList<OGCGeometry>(10); Geometry emptyGeom = null; for (Geometry g = gc.next(); g != null; g = gc.next()) { emptyGeom = g; if (!skipEmpty || !g.isEmpty()) geoms.add(createFromEsriGeometry(g, sr)); } if (geoms.size() == 1) { return geoms.get(0); } else if (geoms.size() == 0) return createFromEsriGeometry(emptyGeom, sr); else return new OGCConcreteGeometryCollection(geoms, sr); }
Example #10
Source Project: barefoot Author: bmwcarit File: PostGISReaderTest.java License: Apache License 2.0 | 6 votes |
@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); }
Example #11
Source Project: arcgis-runtime-demos-android Author: Esri File: LocalGeofence.java License: Apache License 2.0 | 6 votes |
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; } }
Example #12
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_MLineFromWKB.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException { try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } byte [] byteArr = wkb.getBytes(); ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length); byteBuf.put(byteArr); OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf); ogcObj.setSpatialReference(spatialReference); String gType = ogcObj.geometryType(); if (gType.equals("MultiLineString") || gType.equals("LineString")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_MULTILINESTRING, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LOG.error(e.getMessage()); return null; } }
Example #13
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_Aggr_ConvexHull.java License: Apache License 2.0 | 6 votes |
public boolean iterate(BytesWritable geomref) throws HiveException { if (geomref == null) { LogUtils.Log_ArgumentsNull(LOG); return false; } if (firstWKID == -2) { firstWKID = GeometryUtils.getWKID(geomref); if (firstWKID != GeometryUtils.WKID_UNKNOWN) { spatialRef = SpatialReference.create(firstWKID); } } else if (firstWKID != GeometryUtils.getWKID(geomref)) { LogUtils.Log_SRIDMismatch(LOG, geomref, firstWKID); return false; } addGeometryToBuffer(geomref); return (geometries.size() != 0); }
Example #14
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_MPointFromWKB.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException { try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } byte [] byteArr = wkb.getBytes(); ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length); byteBuf.put(byteArr); OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf); ogcObj.setSpatialReference(spatialReference); String gType = ogcObj.geometryType(); if (gType.equals("MultiPoint") || gType.equals("Point")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LOG.error(e.getMessage()); return null; } }
Example #15
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_PointFromWKB.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException { try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } byte [] byteArr = wkb.getBytes(); ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length); byteBuf.put(byteArr); OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf); ogcObj.setSpatialReference(spatialReference); if (ogcObj.geometryType().equals("Point")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_POINT, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LOG.error(e.getMessage()); return null; } }
Example #16
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_Envelope.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable geometryref) { if (geometryref == null || geometryref.getLength() == 0) { LogUtils.Log_ArgumentsNull(LOG); return null; } OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryref); if (ogcGeometry == null){ LogUtils.Log_ArgumentsNull(LOG); return null; } int wkid = GeometryUtils.getWKID(geometryref); SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } Envelope envBound = new Envelope(); ogcGeometry.getEsriGeometry().queryEnvelope(envBound); return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(envBound, spatialReference)); }
Example #17
Source Project: spatial-framework-for-hadoop Author: Esri File: ST_LineFromWKB.java License: Apache License 2.0 | 6 votes |
public BytesWritable evaluate(BytesWritable wkb, int wkid) throws UDFArgumentException { try { SpatialReference spatialReference = null; if (wkid != GeometryUtils.WKID_UNKNOWN) { spatialReference = SpatialReference.create(wkid); } byte [] byteArr = wkb.getBytes(); ByteBuffer byteBuf = ByteBuffer.allocate(byteArr.length); byteBuf.put(byteArr); OGCGeometry ogcObj = OGCGeometry.fromBinary(byteBuf); ogcObj.setSpatialReference(spatialReference); if (ogcObj.geometryType().equals("LineString")) { return GeometryUtils.geometryToEsriShapeBytesWritable(ogcObj); } else { LogUtils.Log_InvalidType(LOG, GeometryUtils.OGCType.ST_LINESTRING, GeometryUtils.OGCType.UNKNOWN); return null; } } catch (Exception e) { // IllegalArgumentException, GeometryException LOG.error(e.getMessage()); return null; } }
Example #18
Source Project: Bats Author: lealone File: GeoFunctions.java License: Apache License 2.0 | 5 votes |
/** Returns whether {@code geom1} intersects {@code geom2}. */ public static boolean ST_Intersects(Geom geom1, Geom geom2) { final Geometry g1 = geom1.g(); final Geometry g2 = geom2.g(); final SpatialReference sr = geom1.sr(); return intersects(g1, g2, sr); }
Example #19
Source Project: Bats Author: lealone File: GeoFunctions.java License: Apache License 2.0 | 5 votes |
/** Computes the union of {@code geom1} and {@code geom2}. */ public static Geom ST_Union(Geom geom1, Geom geom2) { SpatialReference sr = geom1.sr(); final Geometry g = GeometryEngine.union(new Geometry[]{geom1.g(), geom2.g()}, sr); return bind(g, sr); }
Example #20
Source Project: presto Author: prestosql File: GeoFunctions.java License: Apache License 2.0 | 5 votes |
@SqlNullable @Description("Returns the last point of a LINESTRING geometry as a Point") @ScalarFunction("ST_EndPoint") @SqlType(GEOMETRY_TYPE_NAME) public static Slice stEndPoint(@SqlType(GEOMETRY_TYPE_NAME) Slice input) { OGCGeometry geometry = deserialize(input); validateType("ST_EndPoint", geometry, EnumSet.of(LINE_STRING)); if (geometry.isEmpty()) { return null; } MultiPath lines = (MultiPath) geometry.getEsriGeometry(); SpatialReference reference = geometry.getEsriSpatialReference(); return serialize(createFromEsriGeometry(lines.getPoint(lines.getPointCount() - 1), reference)); }
Example #21
Source Project: Quicksql Author: Qihoo360 File: GeoFunctions.java License: MIT License | 5 votes |
protected static Geom bind(Geometry geometry, int srid) { if (geometry == null) { return null; } if (srid == NO_SRID) { return new SimpleGeom(geometry); } return bind(geometry, SpatialReference.create(srid)); }
Example #22
Source Project: Quicksql Author: Qihoo360 File: GeoFunctions.java License: MIT License | 5 votes |
/** Returns whether {@code geom1} intersects {@code geom2}. */ public static boolean ST_Intersects(Geom geom1, Geom geom2) { final Geometry g1 = geom1.g(); final Geometry g2 = geom2.g(); final SpatialReference sr = geom1.sr(); return intersects(g1, g2, sr); }
Example #23
Source Project: Quicksql Author: Qihoo360 File: GeoFunctions.java License: MIT License | 5 votes |
/** Computes the union of the geometries in {@code geomCollection}. */ @SemiStrict public static Geom ST_Union(Geom geomCollection) { SpatialReference sr = geomCollection.sr(); final Geometry g = GeometryEngine.union(new Geometry[] {geomCollection.g()}, sr); return bind(g, sr); }
Example #24
Source Project: defense-solutions-proofs-of-concept Author: Esri File: QueryReportProcessor.java License: Apache License 2.0 | 5 votes |
private String GetDistAsString(Graphic g, SpatialReference inputSr, String units) { com.esri.core.geometry.Geometry geo = g.getGeometry(); com.esri.core.geometry.Geometry curGeo; if(!inputSr.equals(srBuffer)) { curGeo = GeometryEngine.project(geo, inputSr, srBuffer); } else { curGeo=geo; } double tmpDist = GeometryEngine.distance(inGeometry, curGeo, srBuffer); UnitConverter uc = new UnitConverter(); int inUnitWkid = uc.findWkid(srBuffer.getUnit().getName()); String cn = uc.findConnonicalName(units); int outUnitWkid = uc.findWkid(cn); double dist; if(inUnitWkid!=outUnitWkid) { dist = uc.Convert(tmpDist, inUnitWkid, outUnitWkid); } else { dist=tmpDist; } DecimalFormat df = new DecimalFormat("#.00"); return df.format(dist); }
Example #25
Source Project: android-gps-test-tool Author: Esri File: GPSTesterActivityController.java License: Apache License 2.0 | 5 votes |
/** * Helper method that uses latitude/longitude points to programmatically * draw a <code>SimpleMarkerSymbol</code> and adds the <code>Graphic</code> to map. * @param latitude * @param longitude * @param attributes * @param style You defined the style via the Enum <code>SimpleMarkerSymbol.STYLE</code> */ public static void addGraphicLatLon(double latitude, double longitude, Map<String, Object> attributes, SimpleMarkerSymbol.STYLE style,int color,int size, GraphicsLayer graphicsLayer, MapView map){ Point latlon = new Point(longitude,latitude); //Convert latlon Point to mercator map point. Point point = (Point)GeometryEngine.project(latlon,SpatialReference.create(4326), map.getSpatialReference()); //Set market's color, size and style. You can customize these as you see fit SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(color,size, style); Graphic graphic = new Graphic(point, symbol,attributes); graphicsLayer.addGraphic(graphic); }
Example #26
Source Project: defense-solutions-proofs-of-concept Author: Esri File: UnitConverter.java License: Apache License 2.0 | 5 votes |
public double Convert(double v, String unitsin, SpatialReference srout) { Unit u = srout.getUnit(); String srcannonicalName = u.getName(); int srwkid = findWkid(srcannonicalName); String cannonicalName = findConnonicalName(unitsin); int unitwkid = findWkid(cannonicalName); if(srwkid != unitwkid) { v = Convert(v, unitwkid, srwkid); } return v; }
Example #27
Source Project: defense-solutions-proofs-of-concept Author: Esri File: UnitConverter.java License: Apache License 2.0 | 5 votes |
public double Convert(double v, String unitsin, SpatialReference srout) { Unit u = srout.getUnit(); String srcannonicalName = u.getName(); int srwkid = findWkid(srcannonicalName); String cannonicalName = findConnonicalName(unitsin); int unitwkid = findWkid(cannonicalName); if(srwkid != unitwkid) { v = Convert(v, unitwkid, srwkid); } return v; }
Example #28
Source Project: defense-solutions-proofs-of-concept Author: Esri File: QueryReportProcessor.java License: Apache License 2.0 | 5 votes |
private String GetDistAsString(Map<String, Object> objGeo, SpatialReference inputSr, String units) throws JsonParseException, IOException { Geometry geo = generateGeoFromMap(objGeo); com.esri.core.geometry.Geometry curGeo; if(!inputSr.equals(srBuffer)) { curGeo = GeometryEngine.project(geo, inputSr, srBuffer); } else { curGeo=geo; } double tmpDist = GeometryEngine.distance(inGeometry, curGeo, srBuffer); UnitConverter uc = new UnitConverter(); int inUnitWkid = uc.findWkid(srBuffer.getUnit().getName()); String cn = uc.findConnonicalName(units); int outUnitWkid = uc.findWkid(cn); double dist; if(inUnitWkid!=outUnitWkid) { dist = uc.Convert(tmpDist, inUnitWkid, outUnitWkid); } else { dist=tmpDist; } DecimalFormat df = new DecimalFormat("#.00"); return df.format(dist); }
Example #29
Source Project: defense-solutions-proofs-of-concept Author: Esri File: UnitConverter.java License: Apache License 2.0 | 5 votes |
public double Convert(double v, String unitsin, SpatialReference srout) { Unit u = srout.getUnit(); String srcannonicalName = u.getName(); int srwkid = findWkid(srcannonicalName); String cannonicalName = findConnonicalName(unitsin); int unitwkid = findWkid(cannonicalName); if(srwkid != unitwkid) { v = Convert(v, unitwkid, srwkid); } return v; }
Example #30
Source Project: defense-solutions-proofs-of-concept Author: Esri File: UnitConverter.java License: Apache License 2.0 | 5 votes |
public double Convert(double v, String unitsin, SpatialReference srout) { Unit u = srout.getUnit(); String srcannonicalName = u.getName(); int srwkid = findWkid(srcannonicalName); String cannonicalName = findConnonicalName(unitsin); int unitwkid = findWkid(cannonicalName); if(srwkid != unitwkid) { v = Convert(v, unitwkid, srwkid); } return v; }