/**
   * Convert geometry to a different coordinate system. Geometry must have valid SRID.
   *
   * @param ctx Command context used to lookup proj4 parameters from table.
   * @param geom Geometry to transform.
   * @param srid Target SRID; must exist in SPATIAL_REF_SYS table.
   * @return Reprojected geometry.
   * @throws Exception
   */
  public static GeometryType transform(CommandContext ctx, GeometryType geom, int srid)
      throws Exception {
    Geometry jtsGeomSrc = GeometryUtils.getGeometry(geom);

    Geometry jtsGeomTgt = transform(ctx, jtsGeomSrc, srid);

    return GeometryUtils.getGeometryType(jtsGeomTgt, srid);
  }
  public BytesWritable evaluate(BytesWritable geometryref1, DoubleWritable distance) {
    if (geometryref1 == null || geometryref1.getLength() == 0 || distance == null) {
      return null;
    }

    OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryref1);
    if (ogcGeometry == null) {
      LogUtils.Log_ArgumentsNull(LOG);
      return null;
    }

    OGCGeometry bufferedGeometry = ogcGeometry.buffer(distance.get());
    // TODO persist type information (polygon vs multipolygon)
    return GeometryUtils.geometryToEsriShapeBytesWritable(bufferedGeometry);
  }
 @Override
 public void renderAreaSymbol(Bitmap symbol) {
   float[] centerPosition = GeometryUtils.calculateCenterOfBoundingBox(this.coordinates[0]);
   this.pointSymbols.add(
       new SymbolContainer(
           symbol,
           centerPosition[0] - (symbol.getWidth() >> 1),
           centerPosition[1] - (symbol.getHeight() >> 1)));
 }
 public static Position getLatestKnownValueIfSameAsNext(
     Integer packetNumber,
     Unit unit,
     Map<Unit, TreeMap<Integer, Position>> histogramMap,
     Double errorTolerance) {
   Position before = getLatestKnownValue(packetNumber, unit, histogramMap);
   Position after = getNextKnownValue(packetNumber, unit, histogramMap);
   if (before != null
       && after != null
       && GeometryUtils.getDistance3D(before, after) < errorTolerance)
     return new Position(
         (before.getX() + after.getX()) / 2,
         (before.getY() + after.getY()) / 2,
         (before.getZ() + after.getZ()) / 2);
   else return null;
 }
  public DoubleWritable evaluate(BytesWritable geomref) {
    if (geomref == null || geomref.getLength() == 0) {
      LogUtils.Log_ArgumentsNull(LOG);
      return null;
    }

    OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geomref);
    if (ogcGeometry == null) {
      LogUtils.Log_ArgumentsNull(LOG);
      return null;
    }

    Envelope envBound = new Envelope();
    ogcGeometry.getEsriGeometry().queryEnvelope(envBound);
    resultDouble.set(envBound.getXMin());
    return resultDouble;
  }
  private void renderWay(Way way) {
    this.drawingLayer = this.ways.get(getValidLayer(way.layer));
    // TODO what about the label position?

    this.coordinates = way.wayNodes;
    for (int i = 0; i < this.coordinates.length; ++i) {
      for (int j = 0; j < this.coordinates[i].length; j += 2) {
        this.coordinates[i][j] = scaleLongitude(this.coordinates[i][j]);
        this.coordinates[i][j + 1] = scaleLatitude(this.coordinates[i][j + 1]);
      }
    }
    this.shapeContainer = new WayContainer(this.coordinates);

    if (GeometryUtils.isClosedWay(this.coordinates[0])) {
      this.renderTheme.matchClosedWay(this, way.tags, this.currentTile.zoomLevel);
    } else {
      this.renderTheme.matchLinearWay(this, way.tags, this.currentTile.zoomLevel);
    }
  }
 @Override
 public void renderAreaCaption(String caption, float verticalOffset, Paint paint, Paint stroke) {
   float[] centerPosition = GeometryUtils.calculateCenterOfBoundingBox(this.coordinates[0]);
   this.areaLabels.add(
       new PointTextContainer(caption, centerPosition[0], centerPosition[1], paint, stroke));
 }
Example #8
0
	/**
	 * @param g2
	 * @throws IOException
	 */
	private void drawTransition(Map<String, Node> nodes, Graphics2D g2) throws IOException {
		g2.setStroke(DEFAULT_LINE_STROKE);
		g2.setColor(DEFAULT_LINE_STROKE_COLOR);
		for (Node node : nodes.values()) {
			for (Transition transition : node.getTransitions()) {
				String to = transition.getTo();
				Node toNode = nodes.get(to);
				List<Point> trace = new LinkedList<Point>(transition.getLineTrace());
				int len = trace.size() + 2;
				trace.add(0, new Point(node.getCenterX(), node.getCenterY()));
				trace.add(new Point(toNode.getCenterX(), toNode.getCenterY()));
				int[] xPoints = new int[len];
				int[] yPoints = new int[len];
				for (int i = 0; i < len; i++) {
					xPoints[i] = trace.get(i).x;
					yPoints[i] = trace.get(i).y;
				}
				final int taskGrow = 4;
				final int smallGrow = -2;
				int grow = 0;
				if (nodeInfos.get(node.getType()) != null) {
					grow = smallGrow;
				} else {
					grow = taskGrow;
				}
				Point p = GeometryUtils.getRectangleLineCrossPoint(node.getRectangle(), new Point(xPoints[1],
						yPoints[1]), grow);
				if (p != null) {
					xPoints[0] = p.x;
					yPoints[0] = p.y;
				}
				if (nodeInfos.get(toNode.getType()) != null) {
					grow = smallGrow;
				} else {
					grow = taskGrow;
				}
				p = GeometryUtils.getRectangleLineCrossPoint(toNode.getRectangle(), new Point(xPoints[len - 2],
						yPoints[len - 2]), grow);
				if (p != null) {
					xPoints[len - 1] = p.x;
					yPoints[len - 1] = p.y;
				}
				g2.drawPolyline(xPoints, yPoints, len);
				drawArrow(g2, xPoints[len - 2], yPoints[len - 2], xPoints[len - 1], yPoints[len - 1]);
				String label = transition.getLabel();
				if (label != null && label.length() > 0) {
					int cx, cy;
					if (len % 2 == 0) {
						cx = (xPoints[len / 2 - 1] + xPoints[len / 2]) / 2;
						cy = (yPoints[len / 2 - 1] + yPoints[len / 2]) / 2;
					} else {
						cx = xPoints[len / 2];
						cy = yPoints[len / 2];
					}
					Point labelPoint = transition.getLabelPosition();
					if (labelPoint != null) {
						cx += labelPoint.x;
						cy += labelPoint.y;
					}
					cy -= RECT_OFFSET_Y + RECT_OFFSET_Y / 2;
					g2.drawString(label, cx, cy);
				}
			}
		}
	}
Example #9
0
 /** Returns the area contained within the polygon. */
 public float area() {
   float[] vertices = getTransformedVertices();
   return GeometryUtils.polygonArea(vertices, 0, vertices.length);
 }
 /**
  * @param gl
  * @return Coordenada Y OpenGL correspondente à extremidade superior da tela
  */
 protected float getMaxY(GL10 gl) {
   return (GeometryUtils.convertScreenCoordsToWorldCoords(gl, 0, this.h, this.w, this.h))[1];
 }