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


Java Geometry类代码示例

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


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

示例1: testNegExtPolyRings

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
@Test
public void testNegExtPolyRings() {
    try {
        // Single MultiPolygon with two triangles that have negative area from shoelace formula
        // Support for 'V1' MVTs.
        final JtsMvt mvt = loadMvt(
                "src/test/resources/mapbox/vector_tile_js/multi_poly_neg_exters.mvt",
                MvtReader.RING_CLASSIFIER_V1);
        final List<Geometry> geoms = getAllGeometries(mvt);

        assertEquals(1, geoms.size());
        assertTrue(geoms.get(0) instanceof MultiPolygon);
    } catch (IOException e) {
        fail(e.getMessage());
    }
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:17,代码来源:MvtReaderTest.java

示例2: getDatabaseObject

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
@Override
public Object getDatabaseObject(GeometryObject geomObj, Connection connection) throws SQLException {
	Geometry geometry = null;

	switch (geomObj.getGeometryType()) {
	case POLYGON:
		geometry = convertPolygonToJTS(geomObj);
		break;
	case LINE_STRING:
	case POINT:
	case MULTI_LINE_STRING:
	case MULTI_POINT:
	case ENVELOPE:
	case MULTI_POLYGON:
	case SOLID:
	case COMPOSITE_SOLID:
		break;
	}

	if (geometry == null)
		throw new SQLException("Failed to convert geometry to internal database representation.");

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

示例3: validate

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
/**
 * Validate the JtsLayer.
 *
 * @param name mvt layer name
 * @param geometries geometries in the tile
 * @throws IllegalArgumentException when {@code name} or {@code geometries} are null
 */
private static void validate(String name, Collection<Geometry> geometries) {
    if (name == null) {
        throw new IllegalArgumentException("layer name is null");
    }
    if (geometries == null) {
        throw new IllegalArgumentException("geometry collection is null");
    }
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:16,代码来源:JtsLayer.java

示例4: encode

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
/**
 * Encode a {@link JtsMvt} to byte[] ready for writing to a file.
 *
 * @param mvt input to encode to bytes
 * @param mvtLayerParams tile creation parameters
 * @param userDataConverter converts {@link Geometry#userData} to MVT feature tags
 * @return bytes ready for writing to a .mvt
 */
public static byte[] encode(JtsMvt mvt, MvtLayerParams mvtLayerParams, IUserDataConverter userDataConverter) {

    // Build MVT
    final VectorTile.Tile.Builder tileBuilder = VectorTile.Tile.newBuilder();

    for(JtsLayer layer : mvt.getLayers()) {
        final Collection<Geometry> layerGeoms = layer.getGeometries();

        // Create MVT layer
        final VectorTile.Tile.Layer.Builder layerBuilder =
                MvtLayerBuild.newLayerBuilder(layer.getName(), mvtLayerParams);
        final MvtLayerProps layerProps = new MvtLayerProps();

        // MVT tile geometry to MVT features
        final List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(
                layerGeoms, layerProps, userDataConverter);
        layerBuilder.addAllFeatures(features);
        MvtLayerBuild.writeProps(layerBuilder, layerProps);

        // Build MVT layer
        final VectorTile.Tile.Layer vtl = layerBuilder.build();
        tileBuilder.addLayers(vtl);
    }

    // Build MVT
    return tileBuilder.build().toByteArray();
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:36,代码来源:MvtEncoder.java

示例5: singleLayer

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
@Test
public void singleLayer() throws IOException {
    Collection<Geometry> geometries = PointGen.australia();

    JtsLayer layer = new JtsLayer("animals", geometries);
    JtsMvt mvt = new JtsMvt(singletonList(layer));

    final byte[] encoded = MvtEncoder.encode(mvt);
    assertEquals(mvt, decode(encoded));
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:11,代码来源:MvtEncoderTest.java

示例6: australia

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
private static Collection<Geometry> australia() {
    return getPoints(
            createPoint("Koala"),
            createPoint("Wombat"),
            createPoint("Platypus"),
            createPoint("Dingo"),
            createPoint("Croc"));
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:9,代码来源:MvtEncoderTest.java

示例7: uk

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
private static Collection<Geometry> uk() {
    return getPoints(
            createPoint("Hare"),
            createPoint("Frog"),
            createPoint("Robin"),
            createPoint("Fox"),
            createPoint("Hedgehog"),
            createPoint("Bulldog"));
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:10,代码来源:MvtEncoderTest.java

示例8: usa

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
private static Collection<Geometry> usa() {
    return getPoints(
            createPoint("Cougar"),
            createPoint("Raccoon"),
            createPoint("Beaver"),
            createPoint("Wolf"),
            createPoint("Bear"),
            createPoint("Coyote"));
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:10,代码来源:MvtEncoderTest.java

示例9: testLayerCollection

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
@Test
public void testLayerCollection() {
    String layerName = "Points of Interest";
    List<Geometry> geometries = new ArrayList<>();

    JtsLayer layer = new JtsLayer(layerName, geometries);

    String actualName = layer.getName();
    String expectedName = layerName;
    assertEquals(expectedName, actualName);

    Collection<Geometry> actualGeometry = layer.getGeometries();
    Collection<Geometry> expectedGeometry = geometries;
    assertEquals(expectedGeometry, actualGeometry);
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:16,代码来源:JtsLayerTest.java

示例10: testAddGeometry

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
@Test
public void testAddGeometry() {
    String layerName = "Points of Interest";
    List<Geometry> geometries = new ArrayList<>();

    Point point = createPoint(new int[]{51, 0});

    JtsLayer layer = new JtsLayer(layerName, geometries);
    layer.getGeometries().add(point);

    assertTrue(layer.getGeometries().contains(point));
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:13,代码来源:JtsLayerTest.java

示例11: testAddGeometries

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
@Test
public void testAddGeometries() {
    String layerName = "Points of Interest";
    List<Geometry> geometries = new ArrayList<>();

    Point point = createPoint(new int[]{50, 0});
    Point point2 = createPoint(new int[]{51, 1});
    Collection<Geometry> points = Arrays.asList(point, point2);

    JtsLayer layer = new JtsLayer(layerName, geometries);
    layer.getGeometries().addAll(points);

    assertTrue(layer.getGeometries().containsAll(Arrays.asList(point, point2)));
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:15,代码来源:JtsLayerTest.java

示例12: simpleTest

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
@Test
public void simpleTest() {
    try {
        // Load multipolygon z0 tile
        final JtsMvt mvt = loadMvt("src/test/resources/vec_tile_test/0/0/0.mvt");

        List<Geometry> geoms = getAllGeometries(mvt);

        // Debug stats of multipolygon
        final JtsGeomStats stats = JtsGeomStats.getStats(geoms);
        LoggerFactory.getLogger(MvtReaderTest.class).info("Stats: {}", stats);
    } catch (IOException e) {
        fail(e.getMessage());
    }
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:16,代码来源:MvtReaderTest.java

示例13: getAllGeometries

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
private List<Geometry> getAllGeometries(JtsMvt mvt) {
    List<Geometry> allGeoms = new ArrayList<>();
    for (JtsLayer l : mvt.getLayers()) {
        allGeoms.addAll(l.getGeometries());
    }
    return allGeoms;
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:8,代码来源:MvtReaderTest.java

示例14: getPoints

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
private static Collection<Geometry> getPoints(Point... points) {
    return asList(points);
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:4,代码来源:MvtEncoderTest.java

示例15: TileGeomResult

import org.locationtech.jts.geom.Geometry; //导入依赖的package包/类
/**
 * Create TileGeomResult, which contains the intersection of geometry and MVT geometry.
 *
 * @param intGeoms geometry intersecting tile
 * @param mvtGeoms geometry for MVT
 * @throws NullPointerException if intGeoms or mvtGeoms are null
 */
public TileGeomResult(List<Geometry> intGeoms, List<Geometry> mvtGeoms) {
    JdkUtils.requireNonNull(intGeoms);
    JdkUtils.requireNonNull(mvtGeoms);
    this.intGeoms = intGeoms;
    this.mvtGeoms = mvtGeoms;
}
 
开发者ID:wdtinc,项目名称:mapbox-vector-tile-java,代码行数:14,代码来源:TileGeomResult.java


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