com.vividsolutions.jts.geom.Point.<init>()方法的使用及代码示例

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

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

Point.<init>介绍

[英]Constructs a Point with the given coordinate.
[中]用给定的坐标构造一个Point

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Transform into GeometryCollection.
 * 
 * @param geom
 *         input geometry
 * @return
 *         a geometry collection
 */
private static GeometryCollection transformIntoPointGeometryCollection(GeometryCollection gc) {
  UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
  gc.apply(filter);
  Coordinate[] coord = filter.getCoordinates();
  
  Geometry[] geometries = new Geometry[coord.length];
  for (int i = 0 ; i < coord.length ; i++) {
    Coordinate[] c = new Coordinate[] { coord[i] };
    CoordinateArraySequence cs = new CoordinateArraySequence(c);
    geometries[i] = new Point(cs, gc.getFactory());
  }
  
  return new GeometryCollection(geometries, gc.getFactory());
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

/**
 * Transform into GeometryCollection.
 * 
 * @param geom
 *         input geometry
 * @return
 *         a geometry collection
 */
private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) {
  UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
  geom.apply(filter);
  Coordinate[] coord = filter.getCoordinates();
  
  Geometry[] geometries = new Geometry[coord.length];
  for (int i = 0 ; i < coord.length ; i++) {
    Coordinate[] c = new Coordinate[] { coord[i] };
    CoordinateArraySequence cs = new CoordinateArraySequence(c);
    geometries[i] = new Point(cs, geom.getFactory());
  }
  
  return new GeometryCollection(geometries, geom.getFactory());
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Creates a Point using the given CoordinateSequence; a null or empty
 * CoordinateSequence will create an empty Point.
 */
public Point createPoint(CoordinateSequence coordinates) {
  return new Point(coordinates, this);
}

代码示例来源:origin: com.vividsolutions/jts-core

/**
 * Creates a Point using the given CoordinateSequence; a null or empty
 * CoordinateSequence will create an empty Point.
 * 
 * @param coordinates a CoordinateSequence (possibly empty), or null
 * @return the created Point
 */
public Point createPoint(CoordinateSequence coordinates) {
  return new Point(coordinates, this);
}

代码示例来源:origin: Impetus/Kundera

@Test
public void test()
{
  Coordinate coordiates2d = new Coordinate(34.2d,34.4d);
  Coordinate[] coordinates = new Coordinate[1];
  coordinates[0]=coordiates2d;
  
  com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float floatSequence = new com.vividsolutions.jts.geom.impl.PackedCoordinateSequence.Float(coordinates, 2);
  GeometryFactory geoFactory = new GeometryFactory(new PrecisionModel(2));
  Point point = new Point(floatSequence,geoFactory);
  
  point.setSRID(2);
  point.setSurfaceType(SurfaceType.FLAT);
  
  Geometry geometry = new com.vividsolutions.jts.geom.Point(floatSequence,geoFactory);
  Assert.assertTrue(point.contains(geometry));
  Assert.assertTrue(point.getSurfaceType() != null);
  Assert.assertEquals(SurfaceType.FLAT,point.getSurfaceType());
  Assert.assertEquals(2,point.getSRID());
  point = new Point(coordiates2d,new PrecisionModel(2),12);
  Assert.assertNotNull(point);
}

代码示例来源:origin: eu.agrosense.client/model

@Override
public void setPosition(double longitude, double latitude) {
  Coordinate[] coordinates = new Coordinate[]{new Coordinate(longitude, latitude)};
  CoordinateSequence coordSequence = new CoordinateArraySequence(coordinates);
  Point point = new Point(coordSequence, new GeometryFactory());
  setGeometry(point);
}

代码示例来源:origin: nl.cloudfarming.client/fleet-model

@Override
public Point getCentroid() {
  Coordinate[] coordinates = new Coordinate[]{new Coordinate(machine.getLongitude(), machine.getLatitude())};
  CoordinateSequence coordSequence = new CoordinateArraySequence(coordinates);
  return new Point(coordSequence, new GeometryFactory());
}

代码示例来源:origin: osmlab/atlas

@Override
  public Point convert(final Location location)
  {
    final Coordinate coordinate = LOCATION_CONVERTER.convert(location);
    final CoordinateArraySequence sequence = new CoordinateArraySequence(
        new Coordinate[] { coordinate });
    return new Point(sequence, GEOMETRY_FACTORY);
  }
}

代码示例来源:origin: shilad/wikibrain

public static Point getPoint(double lat, double lon) {
    Coordinate[] coords = new Coordinate[1];
    coords[0] = new Coordinate(lon, lat);
    CoordinateArraySequence coordArraySeq = new CoordinateArraySequence(coords);
    return new Point(coordArraySeq, new GeometryFactory(new PrecisionModel(), 4326));
  }
}

代码示例来源:origin: org.wikibrainapi/wikibrain-spatial

public static Point getPoint(double lat, double lon) {
    Coordinate[] coords = new Coordinate[1];
    coords[0] = new Coordinate(lon, lat);
    CoordinateArraySequence coordArraySeq = new CoordinateArraySequence(coords);
    return new Point(coordArraySeq, new GeometryFactory(new PrecisionModel(), 4326));
  }
}

代码示例来源:origin: org.wikibrainapi/wikibrain-spatial

public static void main(String[] args){
  try {
    //Env env = EnvBuilder.envFromArgs(args);
    //Configurator c = env.getConfigurator();
    Point3DDistance eval = new Point3DDistance();
    GeodeticCalculator calc = new GeodeticCalculator();
    Coordinate beijing = new Coordinate(116, 39.9, 0);
    Coordinate la = new Coordinate(-118.25, 34.05, 0);
    Point a = new Point(beijing, new PrecisionModel(), 4326);
    Point b = new Point(la, new PrecisionModel(), 4326);
    System.out.printf("%.2f km\n", eval.calculate3DDistance(a, b, calc)/1000);
  }catch(Exception e){
    e.printStackTrace();;
  }
}

代码示例来源:origin: shilad/wikibrain

public static void main(String[] args){
  try {
    //Env env = EnvBuilder.envFromArgs(args);
    //Configurator c = env.getConfigurator();
    Point3DDistance eval = new Point3DDistance();
    GeodeticCalculator calc = new GeodeticCalculator();
    Coordinate beijing = new Coordinate(116, 39.9, 0);
    Coordinate la = new Coordinate(-118.25, 34.05, 0);
    Point a = new Point(beijing, new PrecisionModel(), 4326);
    Point b = new Point(la, new PrecisionModel(), 4326);
    System.out.printf("%.2f km\n", eval.calculate3DDistance(a, b, calc)/1000);
  }catch(Exception e){
    e.printStackTrace();;
  }
}

代码示例来源:origin: org.geomajas.project/geomajas-project-geometry-jts

private static com.vividsolutions.jts.geom.Geometry createEmpty(GeometryFactory factory, String geometryType)
    throws JtsConversionException {
  if (Geometry.POINT.equals(geometryType)) {
    return new Point(null, factory); // do not use GeometryFactory.createPoint(null,...) as that returns null
  } else if (Geometry.LINEAR_RING.equals(geometryType)) {
    return factory.createLinearRing((com.vividsolutions.jts.geom.Coordinate[]) null);
  } else if (Geometry.LINE_STRING.equals(geometryType)) {
    return factory.createLineString((com.vividsolutions.jts.geom.Coordinate[]) null);
  } else if (Geometry.POLYGON.equals(geometryType)) {
    return factory.createPolygon(null, null);
  } else if (Geometry.MULTI_POINT.equals(geometryType)) {
    return factory.createMultiPoint((Point[]) null);
  } else if (Geometry.MULTI_LINE_STRING.equals(geometryType)) {
    return factory.createMultiLineString(null);
  } else if (Geometry.MULTI_POLYGON.equals(geometryType)) {
    return factory.createMultiPolygon(null);
  } else {
    throw new JtsConversionException("Error while converting to Geomajas: Unknown geometry type.");
  }
}

代码示例来源:origin: ncolomer/elasticsearch-osmosis-plugin

private Geometry buildGeometry() {
  Coordinate[] coordinates = new Coordinate[locations.size()];
  for (int i = 0; i < locations.size(); i++) {
    coordinates[i] = new Coordinate(
        locations.get(i).getLongitude(),
        locations.get(i).getLatitude());
  }
  GeometryFactory factory = SPATIAL_CONTEXT.getGeometryFactory();
  CoordinateSequence sequence = factory.getCoordinateSequenceFactory().create(coordinates);
  switch (getShapeType()) {
  case POINT:
    return new Point(sequence, factory);
  case LINESTRING:
    return new LineString(sequence, factory);
  case POLYGON:
    LinearRing shell = new LinearRing(sequence, factory);
    return new Polygon(shell, null, factory);
  default:
    throw new IllegalStateException("Unrecognized geometry");
  }
}

代码示例来源:origin: senbox-org/snap-desktop

@Override
public void setGeometry(Geometry geometry) {
  Point point = (Point) geometry;
  final Point2D.Double sceneCoords = new Point2D.Double(point.getX(), point.getY());
  Point2D.Double modelCoords = new Point2D.Double();
  Coordinate coordinate;
  try {
    sceneTransformProvider.getSceneToModelTransform().transform(sceneCoords, modelCoords);
    coordinate = new Coordinate(modelCoords.getX(), modelCoords.getY());
  } catch (TransformException e) {
    coordinate = new Coordinate(Double.NaN, Double.NaN);
  }
  this.geometry = new Point(new CoordinateArraySequence(new Coordinate[]{coordinate}), point.getFactory());
}

代码示例来源:origin: nl.cloudfarming.client/geoviewer-api

@Override
public Point getCentroid() {
  if (getInternalGrid() == null) {
    LOGGER.warning("FIXME:getCentroid called while grid is null");
    return null;
  }
  if (centroid == null) {
    Double x = getInternalGrid().getEnvelope2D().getCenterX();
    Double y = getInternalGrid().getEnvelope2D().getCenterY();
    centroid = new Point(new CoordinateArraySequence(new Coordinate[]{new Coordinate(x, y)}), JTSFactoryFinder.getGeometryFactory(null));
  }
  return centroid;
}

代码示例来源:origin: org.geotools/gt-oracle-spatial

Point point = new Point(subList(gf.getCoordinateSequenceFactory(),
      coords, GTYPE, elemInfo, element), gf);

代码示例来源:origin: kodapan/osm-common

public double calculate(Polygon polygon, Coordinate coordinate, double precisionKilometers, GeometryFactory geometryFactory) {
 Point point = new Point(new CoordinateArraySequence(new Coordinate[]{coordinate}), geometryFactory);
 if (polygon.contains(point)) {
  // todo distance to border? well if that should be the case then factor this method out of this class!
  return 0;
 }
 double smallestDistance = Double.MAX_VALUE;
 Coordinate[] coordinates = polygon.getCoordinates();
 for (int i = 1; i < coordinates.length; i++) {
  for (Coordinate interpolated : new LineInterpolation().interpolate(precisionKilometers, coordinates[i - 1], coordinates[i])) {
   double distance = calculate(interpolated, coordinate);
   if (distance < smallestDistance) {
    smallestDistance = distance;
   }
  }
 }
 return smallestDistance;
}

代码示例来源:origin: org.geotools/gt2-render

* (((double) t) / (n + 1)), glyphBounds
    .getCenterY());
Point pp = new Point(c, representativeGeom
    .getPrecisionModel(), representativeGeom.getSRID());
if (p.distance(pp) < mindistance)

代码示例来源:origin: bcdev/beam

@Test
public void testChangingFeature() {
  placemarkGroup.add(createPlacemark("p1", new PixelPos(3, 1), new GeoPos(12, 34)));
  placemarkGroup.add(createPlacemark("p2", new PixelPos(5, 4), new GeoPos(16, 48)));
  placemarkGroup.add(createPlacemark("p3", new PixelPos(6, 2), new GeoPos(-45, 80)));
  assertAreEqual(placemarkGroup, pinFeatureCollection);
  final CoordinateArraySequence coordinates = new CoordinateArraySequence(
      new Coordinate[]{new Coordinate(-30, 70)});
  final SimpleFeature changedFeature = placemarkGroup.get(2).getFeature();
  changedFeature.setDefaultGeometry(new Point(coordinates, new GeometryFactory()));
  assertAreEqual(placemarkGroup, pinFeatureCollection);
  final SimpleFeature[] features = pinFeatureCollection.toArray(new SimpleFeature[pinFeatureCollection.size()]);
  assertEquals(changedFeature.getDefaultGeometry(), features[2].getDefaultGeometry());
}

相关文章