本文整理汇总了Java中com.vividsolutions.jts.geom.Point类的典型用法代码示例。如果您正苦于以下问题:Java Point类的具体用法?Java Point怎么用?Java Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Point类属于com.vividsolutions.jts.geom包,在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flatten
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
/** */
public static Geometry flatten (GeometryCollection gc) {
final List<Point> points = new LinkedList<Point>();
final List<LineString> lines = new LinkedList<LineString>();
final List<Polygon> polygons = new LinkedList<Polygon>();
gc.apply(new GeometryFilter() {
public void filter (Geometry geom) {
if (geom instanceof Point) {
points.add((Point)geom);
} else if (geom instanceof LineString) {
lines.add((LineString)geom);
} else if (geom instanceof Polygon) {
polygons.add((Polygon)geom);
}
}
});
if (!polygons.isEmpty()) {
return gc.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons));
} else if (!lines.isEmpty()) {
return gc.getFactory().createMultiLineString(GeometryFactory.toLineStringArray(lines));
} else {
return gc.getFactory().createMultiPoint(GeometryFactory.toPointArray(points));
}
}
示例2: checkSearchRadius
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
private static void checkSearchRadius(Geometry geom, double value) throws Exception
{
if (geom instanceof Point)
{
if (LocationsServiceSettings.getMaximumSearchRadiusForPoints() > 0 && LocationsServiceSettings.getMaximumSearchRadiusForPoints() < value)
throw new ParameterOutOfRangeException(LocationsErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM, "radius", Double.toString(value), Double.toString(LocationsServiceSettings.getMaximumSearchRadiusForPoints()));
}
else if (geom instanceof LineString)
{
if (LocationsServiceSettings.getMaximumSearchRadiusForLinestrings() > 0 && LocationsServiceSettings.getMaximumSearchRadiusForLinestrings() < value)
throw new ParameterOutOfRangeException(LocationsErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM, "radius", Double.toString(value), Double.toString(LocationsServiceSettings.getMaximumSearchRadiusForLinestrings()));
}
else if (geom instanceof Polygon)
{
if (LocationsServiceSettings.getMaximumSearchRadiusForPolygons() > 0 && LocationsServiceSettings.getMaximumSearchRadiusForPolygons() < value)
throw new ParameterOutOfRangeException(LocationsErrorCodes.PARAMETER_VALUE_EXCEEDS_MAXIMUM, "radius", Double.toString(value), Double.toString(LocationsServiceSettings.getMaximumSearchRadiusForPolygons()));
}
}
示例3: findClosestInpatient
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
public static Hospital findClosestInpatient(Point personLocation) {
double personLat = personLocation.getY();
double personLong = personLocation.getX();
double closestDistance = Double.MAX_VALUE;
Provider closestHospital = null;
for (Provider p : Provider.getServices().get(Provider.INPATIENT)) {
Point hospitalLocation = p.getCoordinates();
double hospitalLat = hospitalLocation.getY();
double hospitalLong = hospitalLocation.getX();
double sphericalDistance = haversine(personLat, personLong, hospitalLat, hospitalLong);
if (sphericalDistance < closestDistance) {
closestDistance = sphericalDistance;
closestHospital = p;
}
}
return (Hospital) closestHospital;
}
示例4: findClosestEmergency
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
public static Hospital findClosestEmergency(Point personLocation) {
double personLat = personLocation.getY();
double personLong = personLocation.getX();
double closestDistance = Double.MAX_VALUE;
Provider closestHospital = null;
for (Provider p : Provider.getServices().get(Provider.EMERGENCY)) {
Point hospitalLocation = p.getCoordinates();
double hospitalLat = hospitalLocation.getY();
double hospitalLong = hospitalLocation.getX();
double sphericalDistance = haversine(personLat, personLong, hospitalLat, hospitalLong);
if (sphericalDistance < closestDistance) {
closestDistance = sphericalDistance;
closestHospital = p;
}
}
return (Hospital) closestHospital;
}
示例5: contains
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
public boolean contains(int x, int y) {
GeometryFactory gf = new GeometryFactory();
Point geom = gf.createPoint(new Coordinate(x, y));
for (Geometry p : maskGeometries) {
if (p.contains(geom)) {
return true;
}
}
return false;
}
示例6: createComplexLayer
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
/**
*
* @param type
* @param layer
* @param parent
* @return
*/
public static GenericLayer createComplexLayer(GeometryImage layer) {
ComplexEditVDSVectorLayer clayer = null;
Geometry frame = layer.getGeometries().get(0);
if (!(frame instanceof Point)) {
layer.remove(frame);
List<Geometry> frames = new ArrayList<Geometry>();
frames.add(frame);
clayer = new ComplexEditVDSVectorLayer(LayerManager.getIstanceManager().getCurrentImageLayer(),
layer.getName(), layer.getGeometryType(), layer);
clayer.addGeometries("image frame", Color.BLUE, 1, GeometryImage.LINESTRING, frames, false);
} else {
clayer = new ComplexEditVDSVectorLayer(LayerManager.getIstanceManager().getCurrentImageLayer(),
layer.getName(), layer.getGeometryType(), layer);
}
return clayer;
}
示例7: mouseClicked
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
/**
*
* @param imagePosition
* @param context
*/
public void mouseClicked(java.awt.Point imagePosition, OpenGLContext context) {
if(isEditable()){
this.selectedGeometry = null;
GeometryFactory gf = new GeometryFactory();
com.vividsolutions.jts.geom.Point p = gf.createPoint(new Coordinate(imagePosition.x, imagePosition.y));
for (Geometry temp : glayer.getGeometries()) {
if(temp instanceof Polygon){
Coordinate[] c=DistanceOp.nearestPoints(temp, p);
com.vividsolutions.jts.geom.Point nearest=gf.createPoint(c[0]);
if (nearest.isWithinDistance(temp,5 * context.getZoom())) {
this.selectedGeometry = temp;
System.out.println(""+temp.getCoordinate().x+","+temp.getCoordinate().y);
LayerPickedData.put(temp, glayer.getAttributes(temp));
break;
}
}
}
}
}
示例8: toJSON
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
public static JSONArray toJSON(Geometry geom, StringBuffer buffer) throws Exception
{
if (geom instanceof Polygon)
{
return toJSON((Polygon)geom);
}
else if (geom instanceof LineString)
{
return toJSON((LineString)geom, false);
}
else if (geom instanceof Point)
{
return toJSON((Point)geom);
}
else if (geom instanceof MultiPolygon)
{
return toJSON((MultiPolygon)geom);
}
else
{
throw new Exception("toJSON function is not implemented for " + geom.getGeometryType());
}
}
示例9: testThatParserExtractsCorrectTypeAndCoordinatesFromArbitraryJson
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
public void testThatParserExtractsCorrectTypeAndCoordinatesFromArbitraryJson() throws IOException {
XContentBuilder pointGeoJson = XContentFactory.jsonBuilder()
.startObject()
.startObject("crs")
.field("type", "name")
.startObject("properties")
.field("name", "urn:ogc:def:crs:OGC:1.3:CRS84")
.endObject()
.endObject()
.field("bbox", "foobar")
.field("type", "point")
.field("bubu", "foobar")
.startArray("coordinates").value(100.0).value(0.0).endArray()
.startObject("nested").startArray("coordinates").value(200.0).value(0.0).endArray().endObject()
.startObject("lala").field("type", "NotAPoint").endObject()
.endObject();
Point expected = GEOMETRY_FACTORY.createPoint(new Coordinate(100.0, 0.0));
assertGeometryEquals(new JtsPoint(expected, SPATIAL_CONTEXT), pointGeoJson);
}
示例10: testFindNearestSegments
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
@Test
@Transactional(readOnly=true)
public void testFindNearestSegments() {
String viewName = "gip_at_frc_0_4";
String version = "16_02_160229";
Point referencePoint = GeometryUtils.createPoint2D(13.04378, 47.80464, 4326);
float radiusInKm = 0.2f;
int maxNrOfSegments = 10;
List<IWaySegment> segments = null;
try {
segments = dao.findNearestSegments(viewName, version, referencePoint, radiusInKm, maxNrOfSegments);
} catch (GraphNotExistsException e) {
log.error("",e);
}
Assert.assertNotNull(segments);
Long[] expectedSegmentIds = new Long[] {901418172L, 901418173L, 901413319L, 901411604L, 901413318L, 901456931L, 901411391L, 901456932L, 901410749L, 901415156L};
int i = 0;
for (IWaySegment segment : segments) {
log.info("" + segment.getId());
Assert.assertEquals(expectedSegmentIds[i++], (Long)segment.getId());
}
}
示例11: setup
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
@BeforeClass
public static void setup() {
TomtomFolder tomtomFolder = mock(TomtomFolder.class);
when(tomtomFolder.getFile("___a0.shp")).thenReturn("src/test/resources/tomtom/boundaries/a0/andorra______________a0.shp");
CapitalProvider capitalProvider = mock(CapitalProvider.class);
Point point = new Point(new PackedCoordinateSequence.Double(new double[]{1.52185, 42.50760}, 2), new GeometryFactory());
Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 0, 1, 7, point);
when(capitalProvider.get(0)).thenReturn(newArrayList(capital));
NameProvider nameProvider = mock(NameProvider.class);
when(nameProvider.getAlternateNames(10200000000008L)).thenReturn(of("name", "Andorra", "name:fr", "Andorre"));
OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
when(osmLevelGenerator.getOsmLevel("andorra", 0)).thenReturn("2");
BoundariesA0Shapefile shapefile = new BoundariesA0Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);
shapefile.serialize("target/tests/");
pbfContent = read(new File("target/tests/a0.osm.pbf"));
}
示例12: setup
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
@BeforeClass
public static void setup() {
TomtomFolder tomtomFolder = mock(TomtomFolder.class);
when(tomtomFolder.getFile("___a2.shp")).thenReturn("src/test/resources/tomtom/boundaries/a2/belbe2___________a2.shp");
NameProvider nameProvider = mock(NameProvider.class);
when(nameProvider.getAlternateNames(10560000000838L)).thenReturn(of("name", "Leuven"));
OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
when(osmLevelGenerator.getOsmLevel("belbe2", 2)).thenReturn("6");
CapitalProvider capitalProvider = mock(CapitalProvider.class);
Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.703077, 50.8756041}, 2), new GeometryFactory());
Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 2, 1, 7, point);
when(capitalProvider.get(2)).thenReturn(newArrayList(capital));
BoundariesA2Shapefile shapefile = new BoundariesA2Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);
shapefile.serialize("target/tests/");
pbfContent = read(new File("target/tests/a2.osm.pbf"));
}
示例13: setup
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
@BeforeClass
public static void setup() {
TomtomFolder tomtomFolder = mock(TomtomFolder.class);
when(tomtomFolder.getFile("___a1.shp")).thenReturn("src/test/resources/tomtom/boundaries/a1/belgium______________a1.shp");
NameProvider nameProvider = mock(NameProvider.class);
when(nameProvider.getAlternateNames(10560000000843L)).thenReturn(of("name", "Brussel", "name:fr", "Bruxelles"));
OsmLevelGenerator osmLevelGenerator = mock(OsmLevelGenerator.class);
when(osmLevelGenerator.getOsmLevel("belgium", 1)).thenReturn("4");
CapitalProvider capitalProvider = mock(CapitalProvider.class);
Point point = new Point(new PackedCoordinateSequence.Double(new double[]{4.868077, 50.4536041}, 2), new GeometryFactory());
Centroid capital = new Centroid(10560000718742L, "Capital Name", "123", 1, 1, 7, point);
when(capitalProvider.get(1)).thenReturn(newArrayList(capital));
BoundariesA1Shapefile shapefile = new BoundariesA1Shapefile(tomtomFolder, capitalProvider, nameProvider, osmLevelGenerator);
shapefile.serialize("target/tests/");
pbfContent = read(new File("target/tests/a1.osm.pbf"));
}
示例14: toBikeStation
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
public static BikeStation toBikeStation(MBPlaceEntity mbPlaceEntity, List<VehicleStatus> vehicleStatusList) {
if (mbPlaceEntity.getGpsPosition() == null) {
return null;
}
Point geoPos = JTSUtil.getPoint(mbPlaceEntity);
return new BikeStation(
mbPlaceEntity.getPlaceId(),
mbPlaceEntity.getGlobalId(),
geoPos,
mbPlaceEntity.getProviderId(),
mbPlaceEntity.getCapacity(),
mbPlaceEntity.getAvailableCapacity(),
mbPlaceEntity.getAvailableVehicles(),
mbPlaceEntity.getName(),
vehicleStatusList
);
}
示例15: toCarStation
import com.vividsolutions.jts.geom.Point; //导入依赖的package包/类
public static CarStation toCarStation(MBPlaceEntity mbPlaceEntity, List<VehicleStatus> vehicleStatusList) {
if (mbPlaceEntity.getGpsPosition() == null) {
return null;
}
Point geoPos = JTSUtil.getPoint(mbPlaceEntity);
return new CarStation(
mbPlaceEntity.getPlaceId(),
mbPlaceEntity.getGlobalId(),
geoPos,
mbPlaceEntity.getProviderId(),
mbPlaceEntity.getCapacity(),
mbPlaceEntity.getAvailableCapacity(),
mbPlaceEntity.getAvailableVehicles(),
mbPlaceEntity.getName(),
vehicleStatusList
);
}