Codota Logo
com.esri.core.geometry
Code IndexAdd Codota to your IDE (free)

How to use com.esri.core.geometry

Best Java code snippets using com.esri.core.geometry (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: prestodb/presto

private static Point computePointsCentroid(MultiVertexGeometry multiVertex)
{
  double xSum = 0;
  double ySum = 0;
  for (int i = 0; i < multiVertex.getPointCount(); i++) {
    Point point = multiVertex.getPoint(i);
    xSum += point.getX();
    ySum += point.getY();
  }
  return new Point(xSum / multiVertex.getPointCount(), ySum / multiVertex.getPointCount());
}
origin: prestodb/presto

private static Polygon getSubPolygon(Polygon polygon, int startIndex, int endIndex)
{
  Polyline boundary = new Polyline();
  boundary.startPath(polygon.getPoint(startIndex));
  for (int i = startIndex + 1; i < endIndex; i++) {
    Point current = polygon.getPoint(i);
    boundary.lineTo(current);
  }
  final Polygon newPolygon = new Polygon();
  newPolygon.add(boundary, false);
  return newPolygon;
}
origin: prestodb/presto

private static void accelerateGeometry(OGCGeometry ogcGeometry, Operator relateOperator)
{
  // Recurse into GeometryCollections
  GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
  while (true) {
    com.esri.core.geometry.Geometry esriGeometry = cursor.next();
    if (esriGeometry == null) {
      break;
    }
    relateOperator.accelerateGeometry(esriGeometry, null, Geometry.GeometryAccelerationDegree.enumMild);
  }
}
origin: prestodb/presto

private static Envelope getEnvelope(OGCGeometry ogcGeometry)
{
  com.esri.core.geometry.Envelope env = new com.esri.core.geometry.Envelope();
  ogcGeometry.getEsriGeometry().queryEnvelope(env);
  return new Envelope(env.getXMin(), env.getXMax(), env.getYMin(), env.getYMax());
}
origin: prestodb/presto

private static Point computeMultiPolygonCentroid(OGCMultiPolygon multiPolygon)
{
  double xSum = 0;
  double ySum = 0;
  double weightSum = 0;
  for (int i = 0; i < multiPolygon.numGeometries(); i++) {
    Point centroid = computePolygonCentroid((Polygon) multiPolygon.geometryN(i).getEsriGeometry());
    Polygon polygon = (Polygon) multiPolygon.geometryN(i).getEsriGeometry();
    double weight = polygon.calculateArea2D();
    weightSum += weight;
    xSum += centroid.getX() * weight;
    ySum += centroid.getY() * weight;
  }
  return new Point(xSum / weightSum, ySum / weightSum);
}
origin: prestodb/presto

private static Point getPolygonSansHolesCentroid(Polygon polygon)
{
  int pointCount = polygon.getPointCount();
  double xSum = 0;
  double ySum = 0;
  double signedArea = 0;
  for (int i = 0; i < pointCount; i++) {
    Point current = polygon.getPoint(i);
    Point next = polygon.getPoint((i + 1) % polygon.getPointCount());
    double ladder = current.getX() * next.getY() - next.getX() * current.getY();
    xSum += (current.getX() + next.getX()) * ladder;
    ySum += (current.getY() + next.getY()) * ladder;
    signedArea += ladder / 2;
  }
  return new Point(xSum / (signedArea * 6), ySum / (signedArea * 6));
}
origin: prestodb/presto

private static Point computeLineCentroid(Polyline polyline)
{
  double xSum = 0;
  double ySum = 0;
  double weightSum = 0;
  for (int i = 0; i < polyline.getPathCount(); i++) {
    Point startPoint = polyline.getPoint(polyline.getPathStart(i));
    Point endPoint = polyline.getPoint(polyline.getPathEnd(i) - 1);
    double dx = endPoint.getX() - startPoint.getX();
    double dy = endPoint.getY() - startPoint.getY();
    double length = sqrt(dx * dx + dy * dy);
    weightSum += length;
    xSum += (startPoint.getX() + endPoint.getX()) * length / 2;
    ySum += (startPoint.getY() + endPoint.getY()) * length / 2;
  }
  return new Point(xSum / weightSum, ySum / weightSum);
}
origin: prestodb/presto

private static Point computePolygonCentroid(Polygon polygon)
{
  int pathCount = polygon.getPathCount();
  if (pathCount == 1) {
    return getPolygonSansHolesCentroid(polygon);
  }
  double xSum = 0;
  double ySum = 0;
  double areaSum = 0;
  for (int i = 0; i < pathCount; i++) {
    int startIndex = polygon.getPathStart(i);
    int endIndex = polygon.getPathEnd(i);
    Polygon sansHoles = getSubPolygon(polygon, startIndex, endIndex);
    Point centroid = getPolygonSansHolesCentroid(sansHoles);
    double area = sansHoles.calculateArea2D();
    xSum += centroid.getX() * area;
    ySum += centroid.getY() * area;
    areaSum += area;
  }
  return new Point(xSum / areaSum, ySum / areaSum);
}
origin: prestodb/presto

public static Envelope getEnvelope(OGCGeometry ogcGeometry)
{
  GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
  Envelope overallEnvelope = new Envelope();
  while (true) {
    Geometry geometry = cursor.next();
    if (geometry == null) {
      return overallEnvelope;
    }
    Envelope envelope = new Envelope();
    geometry.queryEnvelope(envelope);
    overallEnvelope.merge(envelope);
  }
}
origin: prestodb/presto

private static BingTile getTileCoveringLowerRightCorner(Envelope envelope, int zoomLevel)
{
  BingTile tile = latitudeLongitudeToTile(envelope.getYMin(), envelope.getXMax(), zoomLevel);
  // If the tile covering the lower right corner of the envelope overlaps the envelope only
  // at the border then return a tile shifted to the left and/or top
  int deltaX = 0;
  int deltaY = 0;
  Point upperLeftCorner = tileXYToLatitudeLongitude(tile.getX(), tile.getY(), tile.getZoomLevel());
  if (upperLeftCorner.getX() == envelope.getXMax()) {
    deltaX = -1;
  }
  if (upperLeftCorner.getY() == envelope.getYMin()) {
    deltaY = -1;
  }
  if (deltaX != 0 || deltaY != 0) {
    return BingTile.fromCoordinates(tile.getX() + deltaX, tile.getY() + deltaY, tile.getZoomLevel());
  }
  return tile;
}
origin: prestodb/presto

private static Envelope tileToEnvelope(BingTile tile)
{
  Point upperLeftCorner = tileXYToLatitudeLongitude(tile.getX(), tile.getY(), tile.getZoomLevel());
  Point lowerRightCorner = tileXYToLatitudeLongitude(tile.getX() + 1, tile.getY() + 1, tile.getZoomLevel());
  return new Envelope(upperLeftCorner.getX(), lowerRightCorner.getY(), lowerRightCorner.getX(), upperLeftCorner.getY());
}
origin: prestodb/presto

public static int getPointCount(OGCGeometry ogcGeometry)
{
  GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
  int points = 0;
  while (true) {
    com.esri.core.geometry.Geometry geometry = cursor.next();
    if (geometry == null) {
      return points;
    }
    if (geometry.isEmpty()) {
      continue;
    }
    if (geometry instanceof Point) {
      points++;
    }
    else {
      points += ((MultiVertexGeometry) geometry).getPointCount();
    }
  }
}
origin: prestodb/presto

private static boolean withinDistance(GreatCircleDistanceToPoint distanceFunction, double maxDistance, Point point)
{
  return distanceFunction.distance(point.getY(), point.getX()) <= maxDistance;
}
origin: prestodb/presto

public static boolean contains(OGCGeometry ogcGeometry, Envelope envelope)
{
  GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
  while (true) {
    Geometry geometry = cursor.next();
    if (geometry == null) {
      return false;
    }
    if (GeometryEngine.contains(geometry, envelope, null)) {
      return true;
    }
  }
}
origin: prestodb/presto

public static boolean disjoint(Envelope envelope, OGCGeometry ogcGeometry)
{
  GeometryCursor cursor = ogcGeometry.getEsriGeometryCursor();
  while (true) {
    Geometry geometry = cursor.next();
    if (geometry == null) {
      return true;
    }
    if (!GeometryEngine.disjoint(geometry, envelope, null)) {
      return false;
    }
  }
}
origin: prestodb/presto

private static Point tileXYToLatitudeLongitude(int tileX, int tileY, int zoomLevel)
{
  long mapSize = mapSize(zoomLevel);
  double x = (clip(tileX * TILE_PIXELS, 0, mapSize) / mapSize) - 0.5;
  double y = 0.5 - (clip(tileY * TILE_PIXELS, 0, mapSize) / mapSize);
  double latitude = 90 - 360 * Math.atan(Math.exp(-y * 2 * Math.PI)) / Math.PI;
  double longitude = 360 * x;
  return new Point(longitude, latitude);
}
origin: prestodb/presto

private static Envelope getPointEnvelope(BasicSliceInput input)
{
  double x = input.readDouble();
  double y = input.readDouble();
  if (isNaN(x) || isNaN(y)) {
    // TODO: isn't it better to return empty envelope instead?
    return null;
  }
  return new Envelope(x, y, x, y);
}
origin: prestodb/presto

  @Nullable
  private static Envelope merge(@Nullable Envelope left, @Nullable Envelope right)
  {
    if (left == null) {
      return right;
    }
    else if (right == null) {
      return left;
    }
    else {
      right.merge(left);
    }
    return right;
  }
}
origin: prestodb/presto

private static Envelope getEnvelope(OGCGeometry ogcGeometry, double radius)
{
  com.esri.core.geometry.Envelope envelope = new com.esri.core.geometry.Envelope();
  ogcGeometry.getEsriGeometry().queryEnvelope(envelope);
  return new Envelope(envelope.getXMin() - radius, envelope.getXMax() + radius, envelope.getYMin() - radius, envelope.getYMax() + radius);
}
origin: prestodb/presto

private static Envelope readEnvelope(SliceInput input)
{
  verify(input.available() > 0);
  double xMin = input.readDouble();
  double yMin = input.readDouble();
  double xMax = input.readDouble();
  double yMax = input.readDouble();
  return new Envelope(xMin, yMin, xMax, yMax);
}
com.esri.core.geometry

Most used classes

  • Point
  • Envelope
    An envelope is an axis-aligned rectangle.
  • OGCGeometry
    OGC Simple Feature Access specification v.1.2.1
  • Polyline
    A polyline is a collection of one or many paths.
  • Geometry
    Common properties and methods shared by all geometric objects. Geometries are objects that define a
  • Polygon,
  • SpatialReference,
  • GeometryEngine,
  • GeometryCursor,
  • OGCLineString,
  • OGCConcreteGeometryCollection,
  • OGCPolygon,
  • MultiVertexGeometry,
  • OGCGeometryCollection,
  • OGCMultiPolygon,
  • MultiPath,
  • MultiPoint,
  • Line,
  • MapGeometry
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now