com.esri.core.geometry.LinearUnit Java Examples

The following examples show how to use com.esri.core.geometry.LinearUnit. 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 File: BufferProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: BufferProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: ParticleGraphicsEllipseApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void addEllipses(int numberOfEllipses) {
  SimpleMarkerSymbol[] symbols = {symbol4, symbol3, symbol2, symbol1};
  // some values that works well
  int majorAxisLength = 4612483;
  int minorAxisLength = 1843676;

  centerPoint = new Point(500000-5000000, 500000 + 3000000);
  centerGraphicsLayer.addGraphic(new Graphic(centerPoint, null));

  for (int i = 0; i < numberOfEllipses; i++) {
    Point center = new Point(random.nextInt(500000)-5000000, random.nextInt(500000) + 3000000);
    int majorAxisDirection = random.nextInt(60);
    LinearUnit unit = new LinearUnit(LinearUnit.Code.METER);

    Geometry ellipse = GeometryEngine.geodesicEllipse(center, map.getSpatialReference(), majorAxisLength, minorAxisLength,
        majorAxisDirection, pointCount, unit, Geometry.Type.MULTIPOINT);

    if (ellipse instanceof MultiPoint) {
      SimpleMarkerSymbol symbol = symbols[i%4];
      MultiPoint mp = (MultiPoint) ellipse;
      Ellipse currentEllipse = new Ellipse(mp); 
      ellipses.add(currentEllipse);
      int j = 0;
      while (j < mp.getPointCount()) {
        if (j%8==0) {
          Point point = mp.getPoint(j);
          int id = ellipseGraphicsLayer.addGraphic(new Graphic(point, symbol));
          currentEllipse.addPoint(id, j);
        }
        j++;
      }
    }
  }
}
 
Example #4
Source File: QueryReportProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Unit queryUnit(String units)
{
	UnitConverter uc = new UnitConverter();
	String cn = uc.findConnonicalName(units);
	int unitout = uc.findWkid(cn);
	Unit  u = new LinearUnit(unitout);
	return u;
}
 
Example #5
Source File: ParticleGraphicsEllipseApp.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
private void addEllipses(int numberOfEllipses) {
  SimpleMarkerSymbol[] symbols = {symbol4, symbol3, symbol2, symbol1};
  // some values that works well
  int majorAxisLength = 4612483;
  int minorAxisLength = 1843676;

  centerPoint = new Point(500000-5000000, 500000 + 3000000);
  centerGraphicsLayer.addGraphic(new Graphic(centerPoint, null));

  for (int i = 0; i < numberOfEllipses; i++) {
    Point center = new Point(random.nextInt(500000)-5000000, random.nextInt(500000) + 3000000);
    int majorAxisDirection = random.nextInt(60);
    LinearUnit unit = new LinearUnit(LinearUnit.Code.METER);

    Geometry ellipse = GeometryEngine.geodesicEllipse(center, map.getSpatialReference(), majorAxisLength, minorAxisLength,
        majorAxisDirection, pointCount, unit, Geometry.Type.MULTIPOINT);

    if (ellipse instanceof MultiPoint) {
      SimpleMarkerSymbol symbol = symbols[i%4];
      MultiPoint mp = (MultiPoint) ellipse;
      Ellipse currentEllipse = new Ellipse(mp); 
      ellipses.add(currentEllipse);
      int j = 0;
      while (j < mp.getPointCount()) {
        if (j%8==0) {
          Point point = mp.getPoint(j);
          int id = ellipseGraphicsLayer.addGraphic(new Graphic(point, symbol));
          currentEllipse.addPoint(id, j);
        }
        j++;
      }
    }
  }
}
 
Example #6
Source File: CurrentLocationActivity.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onLocationChanged(Location location) {
  if (!locationChanged) {
    // For first fix location, convert to map spatial reference.
    Point currentPt = new Point(location.getLongitude(), location.getLatitude());
    Point currentMapPt = (Point) GeometryEngine.project(currentPt,
        SpatialReference.create(4326), mMapView.getSpatialReference());

    // Use a suitable accuracy value for the typical app usage, if no accuracy
    // value is available.
    float accuracy = 100;
    if (location.hasAccuracy()) {
      accuracy = location.getAccuracy();
    }

    // Convert the accuracy to units of the map, and apply a suitable zoom
    // factor for the app.
    Unit mapUnits = mMapView.getSpatialReference().getUnit();
    double zoomToWidth = 500 * Unit.convertUnits(accuracy,
        Unit.create(LinearUnit.Code.METER), mapUnits);
    Envelope zoomExtent = new Envelope(currentMapPt, zoomToWidth, zoomToWidth);

    // Make sure that the initial zoom is done WITHOUT animation, or it may
    // interfere with autopan.
    mMapView.setExtent(zoomExtent, 0, false);

    // Dont run this again.
    locationChanged = true;

    // Now start the navigation mode.
    mLocDispMgr.setAutoPanMode(LocationDisplayManager.AutoPanMode.NAVIGATION);
  }
}
 
Example #7
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #8
Source File: IncrementalPointProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private void processVertices(GeoEvent ge, Polyline polyln, double distTotal, long start, long end, LinearUnit lu, Boolean projected) throws MessagingException, FieldException
{
	int count = polyln.getPointCount();
	double currentDist = 0;
	long currentTime = start;
	long totalTime = end - start;
	Geometry outGeo = null;
	Point projGeo = null;
	Point lastPoint = null;
	for(int i = 0; i < count; ++i)
	{
		projGeo = polyln.getPoint(i);
		
		if(i!=0)
		{
			Polyline seg = new Polyline();
			seg.startPath(lastPoint);
			seg.lineTo(projGeo);
			double segDist = GeometryEngine.geodesicLength(seg, processSr, lu);
			currentDist += segDist;
			double percent = currentDist/distTotal;
			currentTime = (long) Math.floor((start + (totalTime*percent)));
			
		}
		if(projected)
		{
			outGeo = GeometryEngine.project(projGeo, processSr, outSr);
		}
		else
		{
			outGeo=projGeo;
		}
		MapGeometry outMapGeo = new MapGeometry(outGeo, outSr);
		double minutesFromStart = (currentTime - start)/60000;
		GeoEvent msg = createVertexGeoevent(ge, outMapGeo, currentDist, currentTime, minutesFromStart, i);
		send(msg);
		lastPoint = projGeo;
	}
}
 
Example #9
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #10
Source File: SpatialQProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Unit queryUnit(String units) {
	UnitConverter uc = new UnitConverter();
	String cn = uc.findConnonicalName(units);
	int unitout = uc.findWkid(cn);
	Unit u = LinearUnit.create(unitout);
	return u;
}
 
Example #11
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #12
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #13
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #14
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #15
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #16
Source File: QueryReportProcessor.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
private Unit queryUnit(String units)
{
	UnitConverter uc = new UnitConverter();
	String cn = uc.findConnonicalName(units);
	int unitout = uc.findWkid(cn);
	Unit  u = LinearUnit.create(unitout);
	return u;
}
 
Example #17
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #18
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = LinearUnit.create(wkidin);
	Unit uout = LinearUnit.create(wkidout);
	value = Unit.convertUnits(value, uin, uout);
	return value;
}
 
Example #19
Source File: UnitConverter.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
public double Convert( double value, int wkidin, int wkidout)
{
	Unit uin = new LinearUnit(wkidin);
	Unit uout = new LinearUnit(wkidout);
	value = Unit.convertUnits(value, uin, uout);
	return value;
}