当前位置: 首页>>代码示例>>Java>>正文


Java Point类代码示例

本文整理汇总了Java中org.postgis.Point的典型用法代码示例。如果您正苦于以下问题:Java Point类的具体用法?Java Point怎么用?Java Point使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Point类属于org.postgis包,在下文中一共展示了Point类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reverseMap

import org.postgis.Point; //导入依赖的package包/类
@Override
public Map<String, Object> reverseMap(List<LatLng> latLngs, Action action) {
    Point[] points = new Point[latLngs.size() + 1]; //+1 to close the ring
    List<LatLng> path = latLngs;
    for (int i = 0; i < path.size(); i++) {
        LatLng latLng = path.get(i);
        points[i] = new Point(latLng.getLng(), latLng.getLat());
    }
    //close the ring
    points[points.length - 1] = points[0];
    Polygon polygon = new Polygon(new LinearRing[]{new LinearRing(points)});
    polygon.setSrid(Mappers.WGS84_SRID);
    Map<String, Object> params = new HashMap<>(1);
    params.put(colName, new PGgeometry(polygon));
    return params;
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:17,代码来源:PolygonMapper.java

示例2: distanceBetween

import org.postgis.Point; //导入依赖的package包/类
public double distanceBetween(Point johannesburg, Point pretoria) {
    Connection conn = this.sqlgGraph.tx().getConnection();
    try (Statement statement = conn.createStatement()) {
        if (statement.execute("SELECT ST_Distance_Sphere('" + johannesburg.toString() + "', '" + pretoria.toString() + "')")) {
            ResultSet resultSet = statement.getResultSet();
            if (resultSet.next()) {
                return resultSet.getDouble("st_distance_sphere");
            } else {
                return -1;
            }
        } else {
            return -1;
        }
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:18,代码来源:Gis.java

示例3: testBulkWithinLineString

import org.postgis.Point; //导入依赖的package包/类
@Test
public void testBulkWithinLineString() {
    Point point1 = new Point(26.2044, 28.0456);
    Point point2 = new Point(26.2045, 28.0457);
    LineString lineString1 = new LineString(new Point[] {point1, point2});

    Point point3 = new Point(26.2046, 28.0458);
    LineString lineString2 = new LineString(new Point[] {point1, point3});
    LineString lineString3 = new LineString(new Point[] {point2, point3});

    Point point4 = new Point(26.2047, 28.0459);
    LineString lineString4 = new LineString(new Point[] {point1, point4});

    Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString1);
    Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString2);
    Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString3);
    Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString4);
    this.sqlgGraph.tx().commit();
    List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("line", P.within(lineString1, lineString3, lineString4)).toList();
    Assert.assertEquals(3, vertices.size());
    Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices));
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:23,代码来源:TestGisBulkWithin.java

示例4: getEnvelope

import org.postgis.Point; //导入依赖的package包/类
private GeometryObject getEnvelope(Geometry geometry) {
	double[] coordinates = new double[]{Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE};

	for (int i = 0; i < geometry.numPoints(); ++i) {
		Point point = geometry.getPoint(i);
		if (point.x < coordinates[0])
			coordinates[0] = point.x;
		if (point.y < coordinates[1])
			coordinates[1] = point.y;
		if (point.z < coordinates[2])
			coordinates[2] = point.z;
		if (point.x > coordinates[3])
			coordinates[3] = point.x;
		if (point.y > coordinates[4])
			coordinates[4] = point.y;
		if (point.z > coordinates[5])
			coordinates[5] = point.z;
	}

	return GeometryObject.createEnvelope(coordinates, 3, geometry.getSrid());
}
 
开发者ID:3dcitydb,项目名称:importer-exporter,代码行数:22,代码来源:GeometryConverterAdapter.java

示例5: getMultiPoint

import org.postgis.Point; //导入依赖的package包/类
@Override
public GeometryObject getMultiPoint(Object geomObj) throws SQLException {
	GeometryObject multiPoint = null;

	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		if (geometry.getType() == Geometry.MULTIPOINT) {
			multiPoint = getMultiPoint((MultiPoint)geometry);
		}

		else if (geometry.getType() == Geometry.POINT) {
			Point pointObj = (Point)geometry;
			double[][] coordiantes = new double[1][];
			coordiantes[0] = getPointCoordinates(pointObj);

			multiPoint = GeometryObject.createMultiPoint(coordiantes, pointObj.getDimension(), pointObj.getSrid());
		}
	}

	return multiPoint;
}
 
开发者ID:3dcitydb,项目名称:importer-exporter,代码行数:22,代码来源:GeometryConverterAdapter.java

示例6: getGeometry

import org.postgis.Point; //导入依赖的package包/类
@Override
public GeometryObject getGeometry(Object geomObj) throws SQLException {
	if (geomObj instanceof PGgeometry) {
		Geometry geometry = ((PGgeometry)geomObj).getGeometry();
		switch (geometry.getType()) {
		case Geometry.POINT:
			return getPoint((Point)geometry);
		case Geometry.MULTIPOINT:
			return getMultiPoint((MultiPoint)geometry);
		case Geometry.LINESTRING:
			return getCurve((LineString)geometry);
		case Geometry.MULTILINESTRING:
			return getMultiCurve((MultiLineString)geometry);
		case Geometry.POLYGON:
			return getPolygon((Polygon)geometry);
		case Geometry.MULTIPOLYGON:
			return getMultiPolygon((MultiPolygon)geometry);
		default:
			throw new SQLException("Cannot convert PostGIS geometry type '" + geometry.getType() + "' to internal representation: Unsupported type.");
		}
	}

	return null;
}
 
开发者ID:3dcitydb,项目名称:importer-exporter,代码行数:25,代码来源:GeometryConverterAdapter.java

示例7: before

import org.postgis.Point; //导入依赖的package包/类
@Before
public void before() {
    table = "test_linestring";

    Point[] points = new Point[4];
    points[0] = new Point(123.45d, 23.45d);
    points[1] = new Point(124.45d, 23.45d);
    points[2] = new Point(124.45d, 24.45d);
    points[3] = new Point(123.45d, 24.45d);

    t = new LineString(points);
    t.setSrid(SRID);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:14,代码来源:LineStringTypeHandlerTest.java

示例8: before

import org.postgis.Point; //导入依赖的package包/类
@Before
public void before() {
    table = "test_polygon";

    Point[] points = new Point[5];
    points[0] = new Point(123.45d, 23.45d);
    points[1] = new Point(124.45d, 23.45d);
    points[2] = new Point(124.45d, 24.45d);
    points[3] = new Point(123.45d, 24.45d);
    points[4] = new Point(123.45d, 23.45d);
    LinearRing linearRing = new LinearRing(points);
    t = new Polygon(new LinearRing[]{linearRing});
    t.setSrid(SRID);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:15,代码来源:PolygonTypeHandlerTest.java

示例9: before

import org.postgis.Point; //导入依赖的package包/类
@Before
public void before() {
    table = "test_multipoint";

    Point[] points = new Point[4];
    points[0] = new Point(123.45d, 23.45d);
    points[1] = new Point(124.45d, 23.45d);
    points[2] = new Point(124.45d, 24.45d);
    points[3] = new Point(123.45d, 24.45d);

    t = new MultiPoint(points);
    t.setSrid(SRID);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:14,代码来源:MultiPointTypeHandlerTest.java

示例10: createLinestring

import org.postgis.Point; //导入依赖的package包/类
public static LineString createLinestring(List<FCDEntry> fcdEntries) {
    List<Point> points = new ArrayList<Point>();
    for(FCDEntry fcdEntry : fcdEntries) {
        Point point = new Point(fcdEntry.lon, fcdEntry.lat, (double) fcdEntry.getSpeed());
        point.setM(fcdEntry.getTime()/1000); // we don't need milliseconds
        point.setSrid(4326);
        points.add(point);
    }
    LineString lineString = new LineString(points.toArray(new Point[]{}));
    lineString.srid = 4326;
    return lineString;
}
 
开发者ID:MAGDa-BeuthHS,项目名称:fcd2pgsql,代码行数:13,代码来源:DBUtil.java

示例11: mapRow

import org.postgis.Point; //导入依赖的package包/类
@Override
public List<LatLng> mapRow(ResultSet rs, int rowNum) throws SQLException {
    PGgeometry pggeom = (PGgeometry) rs.getObject(colName);
    Polygon polygon = (Polygon) pggeom.getGeometry();
    List<LatLng> path = new ArrayList<>(polygon.getRing(0).getPoints().length);
    Point[] points = polygon.getRing(0).getPoints();
    for (int i = 0; i < points.length - 1; i++) {
        Point p = points[i];
        path.add(new LatLng(p.getY(), p.getX()));
    }
    return path;
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:13,代码来源:PolygonMapper.java

示例12: toLineString

import org.postgis.Point; //导入依赖的package包/类
static LineString toLineString(List<LatLng> latLngs, int srid) {
    List<Point> points = new ArrayList<>(latLngs.size() + 1);
    for (int i = 0; i < latLngs.size(); i++) {
        LatLng latLng = latLngs.get(i);
        points.add(new Point(latLng.getLng(), latLng.getLat()));
    }
    //close the ring
    if(latLngs.size() == 1) {
        points.add(points.get(0));
    }
    LineString lineString = new LineString(points.toArray(new Point[points.size()]));
    lineString.setSrid(srid);
    return lineString;
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:15,代码来源:Mappers.java

示例13: mapRow

import org.postgis.Point; //导入依赖的package包/类
@Override
public List<LatLng> mapRow(ResultSet rs, int rowNum) throws SQLException {
    PGgeometry pggeom = (PGgeometry) rs.getObject(colName);
    LineString line = (LineString) pggeom.getGeometry();
    Point[] points = line.getPoints();
    if(points.length == 2 && points[0].equals(points[1])) {
        return Arrays.asList(new LatLng(points[0].getY(), points[1].getX()));
    }
    List<LatLng> path = new ArrayList<>(points.length);
    for (Point p  : points) {
        path.add(new LatLng(p.getY(), p.getX()));
    }
    return path;
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:15,代码来源:PolyLineMapper.java

示例14: GeographyPoint

import org.postgis.Point; //导入依赖的package包/类
public GeographyPoint(Point point) {
    this.x = point.x;
    this.y = point.y;
    this.z = point.z;
    this.dimension = point.dimension;
    this.m = point.m;
    this.srid = point.srid;
    this.haveMeasure = point.haveMeasure;
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:10,代码来源:GeographyPoint.java

示例15: testBulkWithinPoint

import org.postgis.Point; //导入依赖的package包/类
@Test
public void testBulkWithinPoint() {
    Point point1 = new Point(26.2044, 28.0456);
    Point point2 = new Point(26.2045, 28.0457);
    Point point3 = new Point(26.2046, 28.0458);
    Point point4 = new Point(26.2047, 28.0459);
    Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point1);
    Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point2);
    Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point3);
    Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point4);
    this.sqlgGraph.tx().commit();
    List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("point", P.within(point1, point3, point4)).toList();
    Assert.assertEquals(3, vertices.size());
    Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices));
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:16,代码来源:TestGisBulkWithin.java


注:本文中的org.postgis.Point类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。