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


Java PreparedGeometry类代码示例

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


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

示例1: iterateOverTriangles

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
public static void iterateOverTriangles(final Polygon polygon, final Consumer<Geometry> action) {
	final double elevation = getContourCoordinates(polygon).averageZ();
	final double sizeTol = FastMath.sqrt(polygon.getArea()) / 100.0;
	final DelaunayTriangulationBuilder dtb = new DelaunayTriangulationBuilder();
	final PreparedGeometry buffered = PREPARED_GEOMETRY_FACTORY.create(polygon.buffer(sizeTol, 5, 0));
	final Envelope3D env = Envelope3D.of(buffered.getGeometry());
	try {
		dtb.setSites(polygon);
		dtb.setTolerance(sizeTol);
		applyToInnerGeometries(dtb.getTriangles(GEOMETRY_FACTORY), (gg) -> {
			final ICoordinates cc = getContourCoordinates(gg);
			if (cc.isCoveredBy(env) && buffered.covers(gg)) {
				cc.setAllZ(elevation);
				gg.geometryChanged();
				action.accept(gg);
			}
		});
	} catch (final LocateFailureException | ConstraintEnforcementException e) {
		final IScope scope = GAMA.getRuntimeScope();
		GamaRuntimeException.warning("Impossible to triangulate: " + new WKTWriter().write(polygon), scope);
		iterateOverTriangles((Polygon) DouglasPeuckerSimplifier.simplify(polygon, 0.1), action);
		return;
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:25,代码来源:GeometryUtils.java

示例2: difference

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
private static IShape difference(final IScope scope, final IShape geom, final List<IShape> geoms,
		final PreparedGeometry ref) {
	if (geom == null) { return null; }
	IShape gR = new GamaShape(geom);
	for (final IShape g : geoms) {

		if (g != null && geom.intersects(g)) {
			gR = Spatial.Operators.minus(scope, gR, g);
			if (gR == null)
				return null;
			if (gR.getGeometries().size() > 1) {
				for (final IShape sh : gR.getGeometries()) {
					if (!ref.disjoint(sh.getInnerGeometry())) {
						gR = sh;
						break;
					}
				}
			} else if (ref.disjoint(gR.getInnerGeometry())) { return null; }
		}
	}

	return gR;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:24,代码来源:Spatial.java

示例3: main

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
public static void main(String[] args)
        throws Exception {
    Geometry circle = createCircle();
    PreparedGeometry prepCircle = PreparedGeometryFactory.prepare(circle);

    int count = 0;
    int inCount = 0;
    for (int i = 0; i < MAX_ITER; i++) {
        count++;
        Point randPt = createRandomPoint();
        if (prepCircle.intersects(randPt)) {
            inCount++;
        }

        //System.out.println("Approximation to PI: " + (4.0 * inCount / (double) count));
    }
    double approxPi = 4.0 * inCount / (double) count;
    double approxDiffPct = 1.0 - approxPi / Math.PI;

    System.out.println("Approximation to PI: " + approxPi
            + "  ( % difference from actual = " + 100 * approxDiffPct + " )"
    );

}
 
开发者ID:Semantive,项目名称:jts,代码行数:25,代码来源:PreparedGeometryExample.java

示例4: intersects

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
/**
 * Finds all {@link PreparedGeometry}s which intersect a given {@link Geometry}
 *
 * @param g the geometry to query by
 * @return a list of intersecting PreparedGeometrys
 */
public List intersects(Geometry g) {
    List result = new ArrayList();
    List candidates = query(g);
    for (Iterator it = candidates.iterator(); it.hasNext(); ) {
        PreparedGeometry prepGeom = (PreparedGeometry) it.next();
        if (prepGeom.intersects(g)) {
            result.add(prepGeom);
        }
    }
    return result;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:18,代码来源:SearchUsingPreparedGeometryIndex.java

示例5: intersectingFeatures

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
/** */
public List<VectorFeature> intersectingFeatures (Geometry geom) {
    final PreparedGeometry pGeom = PreparedGeometryFactory.prepare(geom);
    final List<VectorFeature> result = new ArrayList<VectorFeature>();
    _spatialIndex.query(geom.getEnvelopeInternal(), new ItemVisitor() {
            public void visitItem (Object item) {
                VectorFeature feature = (VectorFeature)item;
                if (pGeom.intersects(feature.getGeometry())) {
                    result.add(feature);
                }
            }
        });
    return result;
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:15,代码来源:VectorDataset.java

示例6: findRegionCrossingPoint

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
private static TimedPosition findRegionCrossingPoint(Shapefile region, Fix fix1, Fix fix2) {

        Coordinate[] coords = new Coordinate[] { new Coordinate(fix1.lon(), fix1.lat()),
                new Coordinate(fix2.lon(), fix2.lat()) };
        LineString line = new GeometryFactory().createLineString(coords);
        for (PreparedGeometry g : region.geometries()) {
            if (g.crosses(line)) {
                Geometry intersection = g.getGeometry().intersection(line);
                // expecting just one point
                Coordinate coord = intersection.getCoordinate();
                double longitude = coord.x;
                double latitude = coord.y;
                Position a = Position.create(fix1.lat(), fix1.lon());
                Position b = Position.create(fix2.lat(), fix2.lon());
                Position c = Position.create(latitude, longitude);
                double ac = a.getDistanceToKm(c);
                double bc = b.getDistanceToKm(c);
                if (ac == 0) {
                    return new TimedPosition(fix1.lat(), fix1.lon(), fix1.time());
                } else if (bc == 0) {
                    return new TimedPosition(fix2.lat(), fix2.lon(), fix2.time());
                } else {
                    // predict the timestamp based on distance from a and b
                    long diff = fix2.time() - fix1.time();
                    long t = Math.round(fix1.time() + ac * diff / (ac + bc));
                    return new TimedPosition(latitude, longitude, t);
                }
            }
        }
        throw new RuntimeException("crossing not found");
    }
 
开发者ID:amsa-code,项目名称:risky,代码行数:32,代码来源:VoyageDatasetProducer.java

示例7: contains

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
public static boolean contains(GeometryFactory gf, Collection<PreparedGeometry> geometries,
        double lat, double lon) {
    Point point = gf.createPoint(new Coordinate(lon, lat));
    for (PreparedGeometry g : geometries) {
        if (g.contains(point))
            return true;
    }
    return false;
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:10,代码来源:GeometryUtil.java

示例8: load

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
private Shapefile load() {
    if (state.compareAndSet(NOT_LOADED, LOADED)) {
        try {
            final List<PreparedGeometry> geometries = new ArrayList<>();
            for (String typeName : datastore.getTypeNames()) {
                SimpleFeatureSource source = datastore.getFeatureSource(typeName);
                crs = source.getBounds().getCoordinateReferenceSystem();
                final SimpleFeatureCollection features = source.getFeatures();
                SimpleFeatureIterator it = features.features();
                while (it.hasNext()) {
                    SimpleFeature feature = it.next();
                    Geometry g = (Geometry) feature.getDefaultGeometry();
                    if (bufferDistance > 0)
                        g = g.buffer(bufferDistance);
                    geometries.add(PreparedGeometryFactory.prepare(g));
                    this.features.add(feature);
                }
                it.close();
            }
            this.geometries = geometries;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } else if (state.get() == CLOSED)
        throw new RuntimeException("Shapefile is closed and can't be accessed");
    return this;
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:28,代码来源:Shapefile.java

示例9: mbr

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
public Rect mbr() {
    // TODO assumes that shapefile is using WGS84?
    load();
    Rect r = null;
    for (PreparedGeometry g : geometries) {
        Coordinate[] v = g.getGeometry().getEnvelope().getCoordinates();
        System.out.println(Arrays.toString(v));
        Rect rect = new Rect(v[0].y, v[0].x, v[2].y, v[2].x);
        if (r == null)
            r = rect;
        else
            r = r.add(rect);
    }
    return r;
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:16,代码来源:Shapefile.java

示例10: contains

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
private static boolean contains(GeometryFactory gf, Collection<PreparedGeometry> geometries,
        double lat, double lon) {
    for (PreparedGeometry g : geometries) {
        if (g.contains(gf.createPoint(new Coordinate(lon, lat))))
            return true;
    }
    return false;
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:9,代码来源:ShipTypeBreakdownMain.java

示例11: linkBasinWithNetwork

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
private void linkBasinWithNetwork() throws Exception {
    FeatureExtender fExt = new FeatureExtender(inNetwork.getSchema(), new String[]{NetworkChannel.NETNUMNAME},
            new Class[]{Integer.class});

    DefaultFeatureCollection newCollection = new DefaultFeatureCollection();

    SimpleFeatureIterator hillslopeFeatures = inHillslope.features();
    while( hillslopeFeatures.hasNext() ) {
        SimpleFeature hFeature = hillslopeFeatures.next();
        Object netNum = hFeature.getAttribute(NetworkChannel.NETNUMNAME);
        Geometry hGeometry = (Geometry) hFeature.getDefaultGeometry();
        PreparedGeometry preparedHGeometry = PreparedGeometryFactory.prepare(hGeometry);
        SimpleFeatureIterator netFeatures = inNetwork.features();
        while( netFeatures.hasNext() ) {
            SimpleFeature nFeature = netFeatures.next();
            Geometry geometry = (Geometry) nFeature.getDefaultGeometry();
            if (geometry.getNumGeometries() != 1) {
                throw new ModelsRuntimeException("The network geometries have to be single lines.", this);
            }
            LineString nLine = (LineString) geometry.getGeometryN(0);
            Point startPoint = nLine.getStartPoint();
            if (preparedHGeometry.contains(startPoint)) {
                SimpleFeature extendFeature = fExt.extendFeature(nFeature, new Object[]{netNum});
                newCollection.add(extendFeature);
                break;
            }
        }
    }
    inNetwork = newCollection;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:31,代码来源:OmsAdige.java

示例12: compare

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
@Override
public boolean compare(
		final Geometry dataGeometry,
		final PreparedGeometry constraintGeometry ) {
	// This method is same as Geometry.equalsTopo which is
	// computationally expensive.
	// See equalsExact for quick structural equality
	return constraintGeometry.getGeometry().equals(
			dataGeometry);
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:11,代码来源:SpatialQueryFilter.java

示例13: PreparedFeature

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
private PreparedFeature(
        final Feature feature,
        final PreparedGeometry preparedGeometry)
{
    this.feature = feature;
    this.preparedGeometry = preparedGeometry;
}
 
开发者ID:mraad,项目名称:GeoEnrichment,代码行数:8,代码来源:SearchShapefileIndexPolygon.java

示例14: setup

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
@Override
public void setup(
        final Configuration configuration,
        final List<ColumnInterface> columnList) throws IOException
{
    m_spatialIndex = new STRtree();
    m_buffer = configuration.getFloat(GeoEnrichmentJob.KEY_BUFFER, 0.000001F);

    final URL url = getUrl(configuration);
    final ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
    final Map params = new HashMap();
    params.put(ShapefileDataStoreFactory.URLP.key, url);
    final DataStore dataStore = factory.createDataStore(params);
    try
    {
        final String[] typeNames = dataStore.getTypeNames();
        final SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeNames[0]);
        m_geometryName = featureSource.getSchema().getGeometryDescriptor().getLocalName();
        final SimpleFeatureCollection featureCollection = featureSource.getFeatures();
        featureCollection.accepts(new FeatureVisitor()
        {
            public void visit(final Feature feature)
            {
                final Geometry geometry = (Geometry) feature.getProperty(m_geometryName).getValue();
                final PreparedGeometry preparedGeometry = PreparedGeometryFactory.prepare(geometry);
                m_spatialIndex.insert(geometry.getEnvelopeInternal(), new PreparedFeature(feature, preparedGeometry));
            }
        }, new NullProgressListener());
    }
    finally
    {
        dataStore.dispose();
    }
}
 
开发者ID:mraad,项目名称:GeoEnrichment,代码行数:35,代码来源:SearchShapefileIndexPolygon.java

示例15: intersectionSim

import com.vividsolutions.jts.geom.prep.PreparedGeometry; //导入依赖的package包/类
private static Geometry intersectionSim(
    PreparedGeometry pg, Geometry g2)
{
  PreparedPolygon ppoly = (PreparedPolygon) pg;
  FastSegmentSetIntersectionFinder intf = ppoly.getIntersectionFinder();
  
  Coordinate[] pts = g2.getCoordinates();
  
  List segStrings = SegmentStringUtil.extractSegmentStrings(g2);
  intf.intersects(segStrings );
  return g2;
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:13,代码来源:GeomPrepFunction.java


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