org.locationtech.jts.geom.Point.getX()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(524)

本文整理了Java中org.locationtech.jts.geom.Point.getX()方法的一些代码示例,展示了Point.getX()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Point.getX()方法的具体详情如下:
包路径:org.locationtech.jts.geom.Point
类名称:Point
方法名:getX

Point.getX介绍

暂无

代码示例

代码示例来源:origin: graphhopper/graphhopper

public static GHPoint create(Point point) {
  return new GHPoint(point.getY(), point.getX());
}

代码示例来源:origin: graphhopper/graphhopper

pl = instructions.get(instructions.size() - 2).getPoints();
pl.add(ptLeg.stops.get(0).geometry.getY(), ptLeg.stops.get(0).geometry.getX());
for (Trip.Stop stop : ptLeg.stops.subList(0, ptLeg.stops.size() - 1)) {
  pl.add(stop.geometry.getY(), stop.geometry.getX());
arrivalPointList.add(arrivalStop.geometry.getY(), arrivalStop.geometry.getX());
Instruction arrivalInstruction = new Instruction(Instruction.PT_END_TRIP, arrivalStop.stop_name, InstructionAnnotation.EMPTY, arrivalPointList);
if (ptLeg.isInSameVehicleAsPrevious) {

代码示例来源:origin: geotools/geotools

public static double getX(Geometry arg0) {
  if (!(arg0 instanceof Point)) return 0d;
  Point _this = (Point) arg0;
  return _this.getX();
}

代码示例来源:origin: geotools/geotools

public double getX() {
  return point.getX();
}

代码示例来源:origin: locationtech/spatial4j

@Override
public double getX() {
 return isEmpty() ? Double.NaN : pointGeom.getX();
}

代码示例来源:origin: geotools/geotools

/** @see java.awt.geom.PathIterator#currentSegment(double[]) */
  public int currentSegment(double[] coords) {
    if (!done && !moved) {
      coords[0] = point.getX();
      coords[1] = point.getY();
      at.transform(coords, 0, coords, 0, 1);

      return SEG_MOVETO;
    } else {
      coords[0] = point.getX();
      coords[1] = point.getY();
      at.transform(coords, 0, coords, 0, 1);

      moved = true;
      return SEG_LINETO;
    }
  }
}

代码示例来源:origin: geotools/geotools

public static double dx(LineString ls) {
  return (ls.getPointN(ls.getNumPoints() - 1).getX() - ls.getPointN(0).getX());
}

代码示例来源:origin: geotools/geotools

private static Cell getCentroidCell(MultiPolygon poly) {
    Point p = poly.getCentroid();
    return new Cell(p.getX(), p.getY(), 0, poly);
  }
}

代码示例来源:origin: geotools/geotools

@DescribeProcess(
  title = "Get X Ordinate",
  description =
      "Returns the X value (first ordinate) for point geometries. For other geometry types returns the X value of the centroid."
)
@DescribeResult(description = "X value of point")
public static double getX(
    @DescribeParameter(name = "geom", description = "Input point") Point point) {
  return point.getX();
}

代码示例来源:origin: geotools/geotools

public GeographicGenerator(
    Point center, int quadrantSegments, CoordinateReferenceSystem crs) {
  this.quadrantSegments = quadrantSegments;
  this.center = center;
  this.calculator = new GeodeticCalculator(crs);
  latLon = isLatLonOrder(crs.getCoordinateSystem());
  if (latLon) {
    calculator.setStartingGeographicPoint(center.getY(), center.getX());
  } else {
    calculator.setStartingGeographicPoint(center.getX(), center.getY());
  }
}

代码示例来源:origin: geotools/geotools

LabelPainter painter) {
tempTransform.translate(centroid.getX(), centroid.getY());

代码示例来源:origin: geotools/geotools

private static Geometry pointInGeometry(Geometry g) {
  Point p = g.getCentroid();
  if (g instanceof Polygon) {
    // if the geometry is heavily generalized centroid computation may fail and return NaN
    if (Double.isNaN(p.getX()) || Double.isNaN(p.getY()))
      return g.getFactory().createPoint(g.getCoordinate());
    // otherwise let's check if the point is inside. Again, this check and
    // "getInteriorPoint"
    // will work only if the geometry is valid
    if (g.isValid() && !g.contains(p)) {
      try {
        p = g.getInteriorPoint();
      } catch (Exception e) {
        // generalized geometries might make interior point go bye bye
        return p;
      }
    } else {
      return p;
    }
  }
  return p;
}

代码示例来源:origin: geotools/geotools

/**
 * This method adds the GridConvergence Angle attribute to the Point feature if it is
 * needed.
 *
 * @param point Input Point to handle.
 */
private void gridConvergenceAngleManagement(Point point) throws Exception {
  // If the GridConvergence Angle correction is not requested, then nothing is done
  if (fc.gridConvergenceAngleCorrectionNeeded) {
    //
    // Calculate convergence angle
    //
    sourceCRSPosition.setLocation(point.getX(), point.getY());
    fc.reprojectionTransformation.transform(sourceCRSPosition, targetCRSPosition);
    // Calculation of the Angle
    double convAngle =
        fc.gridConvergenceAngleManager.getConvergenceAngle(targetCRSPosition);
    fb.add(convAngle);
  }
}

代码示例来源:origin: geotools/geotools

@Test
public void testToGeographicGeometry() throws Exception {
  // This time we are in north / east order
  CoordinateReferenceSystem gda94 = CRS.decode("EPSG:4939", true);
  GeometryFactory gf = new GeometryFactory();
  Point point =
      gf.createPoint(
          new Coordinate(130.882672103999, -16.4463909341494, 97.009018073082));
  Point world = (Point) JTS.toGeographic(point, gda94);
  assertEquals(point.getX(), world.getX(), 0.00000005);
  assertEquals(point.getY(), world.getY(), 0.00000005);
}

代码示例来源:origin: geotools/geotools

assertEquals(i / 1d, point.getX(), 0.1);
assertEquals(i / 1d, point.getX(), 0.1);

代码示例来源:origin: locationtech/spatial4j

/**
 * Reads WKT from the {@code str} via JTS's {@link org.locationtech.jts.io.WKTReader}.
 * @param str
 * @param reader <pre>new WKTReader(ctx.getGeometryFactory()))</pre>
 * @return Non-Null
 */
protected Shape parseIfSupported(String str, WKTReader reader) throws ParseException {
 try {
  Geometry geom = reader.read(str);
  //Normalizes & verifies coordinates
  checkCoordinates(geom);
  if (geom instanceof org.locationtech.jts.geom.Point) {
   org.locationtech.jts.geom.Point ptGeom = (org.locationtech.jts.geom.Point) geom;
   if (getShapeFactory().useJtsPoint())
    return new JtsPoint(ptGeom, (JtsSpatialContext) ctx);
   else
    return getShapeFactory().pointXY(ptGeom.getX(), ptGeom.getY());
  } else if (geom.isRectangle()) {
   return getShapeFactory().makeRectFromRectangularPoly(geom);
  } else {
   return getShapeFactory().makeShapeFromGeometry(geom);
  }
 } catch (InvalidShapeException e) {
  throw e;
 } catch (Exception e) {
  throw new InvalidShapeException("error reading WKT: "+e.toString(), e);
 }
}

代码示例来源:origin: geotools/geotools

@Test
public void testToGeographicGeometry() throws Exception {
  // This time we are in north / east order
  String wkt =
      "GEOGCS[\"GDA94\","
          + " DATUM[\"Geocentric Datum of Australia 1994\","
          + "  SPHEROID[\"GRS 1980\", 6378137.0, 298.257222101, AUTHORITY[\"EPSG\",\"7019\"]],"
          + "  TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "
          + " AUTHORITY[\"EPSG\",\"6283\"]], "
          + " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
          + " UNIT[\"degree\", 0.017453292519943295], "
          + " AXIS[\"Geodetic latitude\", NORTH], "
          + " AXIS[\"Geodetic longitude\", EAST], "
          + " AXIS[\"Ellipsoidal height\", UP], "
          + " AUTHORITY[\"EPSG\",\"4939\"]]";
  CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt);
  GeometryFactory gf = new GeometryFactory();
  Point point =
      gf.createPoint(
          new Coordinate(-16.4463909341494, 130.882672103999, 97.009018073082));
  Point world = (Point) JTS.toGeographic(point, gda94);
  assertEquals(point.getX(), world.getY(), 0.00000005);
  assertEquals(point.getY(), world.getX(), 0.00000005);
}

代码示例来源:origin: geotools/geotools

assertThat(reprojectedFeature, notNullValue());
Point geometry = (Point) reprojectedFeature.getDefaultGeometry();
checkDoubleValue(geometry.getX(), 222638.9816, 0.0001);
checkDoubleValue(geometry.getY(), 111325.1429, 0.0001);

代码示例来源:origin: geotools/geotools

public void testWithoutGmlProperties() throws Exception {
  Element feature = GML3MockData.feature(document, document);
  feature.setAttributeNS(GML.NAMESPACE, "id", "fid.1");
  SimpleFeature f = (SimpleFeature) parse();
  assertNotNull(feature);
  assertEquals("fid.1", f.getID());
  Point p = (Point) f.getDefaultGeometry();
  assertNotNull(p);
  assertEquals(1.0, p.getX(), 0d);
  assertEquals(2.0, p.getY(), 0d);
  Integer i = (Integer) f.getAttribute("count");
  assertNotNull(i);
  assertEquals(1, i.intValue());
}

代码示例来源:origin: geotools/geotools

@Test
public void testToGeographic() throws Exception {
  String wkt =
      "GEOGCS[\"GDA94\","
          + " DATUM[\"Geocentric Datum of Australia 1994\","
          + "  SPHEROID[\"GRS 1980\", 6378137.0, 298.257222101, AUTHORITY[\"EPSG\",\"7019\"]],"
          + "  TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "
          + " AUTHORITY[\"EPSG\",\"6283\"]], "
          + " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
          + " UNIT[\"degree\", 0.017453292519943295], "
          + " AXIS[\"Geodetic longitude\", EAST], "
          + " AXIS[\"Geodetic latitude\", NORTH], "
          + " AXIS[\"Ellipsoidal height\", UP], "
          + " AUTHORITY[\"EPSG\",\"4939\"]]";
  CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt);
  GeometryFactory gf = new GeometryFactory();
  Point point = gf.createPoint(new Coordinate(130.875825803896, -16.4491956225999, 0.0));
  Geometry worldPoint = JTS.toGeographic(point, gda94);
  assertTrue(worldPoint instanceof Point);
  assertEquals(point.getX(), worldPoint.getCoordinate().x, 0.00000001);
}

相关文章