• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PreparedGeometryFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的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


示例2: insert

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
/**
 * Inserts a collection of Geometrys into the index.
 *
 * @param geoms a collection of Geometrys to insert
 */
public void insert(Collection geoms) {
    for (Iterator i = geoms.iterator(); i.hasNext(); ) {
        Geometry geom = (Geometry) i.next();
        index.insert(geom.getEnvelopeInternal(), PreparedGeometryFactory.prepare(geom));
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:12,代码来源:SearchUsingPreparedGeometryIndex.java


示例3: intersectingFeatures

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的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


示例4: load

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的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


示例5: FastLiteShape

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public FastLiteShape( Geometry geom ) {
    super(geom, new AffineTransform(), false);
    this.prepared = PreparedGeometryFactory.prepare(geom);
    GeometryFactory gf = new GeometryFactory();
    pointCS = new LiteCoordinateSequence(1, 2);
    point = gf.createPoint(pointCS);
    rectCS = new LiteCoordinateSequence(5, 2);
    rect = gf.createPolygon(gf.createLinearRing(rectCS), null);
    // System.out.println("Crop area: " + geom);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:11,代码来源:FastLiteShape.java


示例6: intersects

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
/**
 * Check for intersection.
 * 
 * @param geometry the geometry to check against.
 * @param usePrepared use prepared geometry.
 * @return true if the geometries intersect.
 */
public boolean intersects( Geometry geometry, boolean usePrepared ) {
    if (!getEnvelope().intersects(geometry.getEnvelopeInternal())) {
        return false;
    }
    if (usePrepared) {
        if (preparedGeometry == null) {
            preparedGeometry = PreparedGeometryFactory.prepare(getGeometry());
        }
        return preparedGeometry.intersects(geometry);
    } else {
        return getGeometry().intersects(geometry);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:21,代码来源:FeatureMate.java


示例7: covers

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
/**
 * Check for cover.
 * 
 * @param geometry the geometry to check against.
 * @param usePrepared use prepared geometry.
 * @return true if the current geometries covers the supplied one.
 */
public boolean covers( Geometry geometry, boolean usePrepared ) {
    if (!getEnvelope().covers(geometry.getEnvelopeInternal())) {
        return false;
    }
    if (usePrepared) {
        if (preparedGeometry == null) {
            preparedGeometry = PreparedGeometryFactory.prepare(getGeometry());
        }
        return preparedGeometry.covers(geometry);
    } else {
        return getGeometry().covers(geometry);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:21,代码来源:FeatureMate.java


示例8: linkBasinWithNetwork

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的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


示例9: setup

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的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


示例10: intersects

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public static boolean intersects(Geometry cachedGeom, Geometry g2) 
{ 
  if (intersectsCacheGeom == null
      || intersectsCacheGeom != cachedGeom) {
    intersectsCacheGeom = cachedGeom;
    intersectsCacheGeomPrep = PreparedGeometryFactory.prepare(cachedGeom);
  }
  return intersectsCacheGeomPrep.intersects(g2); 
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:10,代码来源:GeomPrepFunction.java


示例11: contains

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public static boolean contains(Geometry cachedGeom, Geometry g2) 
  { 
    if (containsCacheGeom == null
        || containsCacheGeom != cachedGeom) {
      containsCacheGeom = cachedGeom;
      containsCacheGeomPrep = PreparedGeometryFactory.prepare(cachedGeom);
      
//      System.out.println(hitCount);
      hitCount = 0;
    }
    hitCount++;
    return containsCacheGeomPrep.contains(g2); 
  }
 
开发者ID:dr-jts,项目名称:jeql,代码行数:14,代码来源:GeomPrepFunction.java


示例12: intersection

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public static Geometry intersection(Geometry cachedGeom, Geometry g2) 
{ 
  if (intersectionCacheGeom == null
      || intersectionCacheGeom != cachedGeom) {
    intersectionCacheGeom = cachedGeom;
    intersectionCacheGeomPrep = PreparedGeometryFactory.prepare(cachedGeom);
  }
  hitCount++;
  if (! intersectionCacheGeomPrep.intersects(g2))
    return g2.getFactory().createGeometryCollection(null);
  if (intersectionCacheGeomPrep.contains(g2))
    return g2;
  return cachedGeom.intersection(g2);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:15,代码来源:GeomPrepFunction.java


示例13: intersectionSim

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public static Geometry intersectionSim(Geometry cachedGeom, Geometry g2) 
{ 
  if (intersectionCacheGeom == null
      || intersectionCacheGeom != cachedGeom) {
    intersectionCacheGeom = cachedGeom;
    intersectionCacheGeomPrep = PreparedGeometryFactory.prepare(cachedGeom);
  }
  hitCount++;
  if (! intersectionCacheGeomPrep.intersects(g2))
    return g2.getFactory().createGeometryCollection(null);
  if (intersectionCacheGeomPrep.contains(g2))
    return g2;
  return intersectionSim(intersectionCacheGeomPrep, g2);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:15,代码来源:GeomPrepFunction.java


示例14: cacheFind

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
private static PreparedGeometry cacheFind(Geometry g)
{
  PreparedGeometry pg = cache.get(g);
  if (pg == null) {
    pg = PreparedGeometryFactory.prepare(g);
    cache.put(g, pg);
    //System.out.println("cache size = " + cache.size());
  }
  return pg;
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:11,代码来源:GeomPrepAllFunction.java


示例15: intersectsPrep

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public static boolean intersectsPrep(Geometry g1, Geometry g2) 
{ 
  if (intersectsCacheGeom == null
      || intersectsCacheGeom != g1) {
    intersectsCacheGeom = g1;
    intersectsCacheGeomPrep = PreparedGeometryFactory.prepare(g1);
  }
  return intersectsCacheGeomPrep.intersects(g2); 
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:10,代码来源:GeomExpFunction.java


示例16: containsPrep

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public static boolean containsPrep(Geometry g1, Geometry g2) 
  { 
    if (containsCacheGeom == null
        || containsCacheGeom != g1) {
      containsCacheGeom = g1;
      containsCacheGeomPrep = PreparedGeometryFactory.prepare(g1);
      
//      System.out.println(hitCount);
      hitCount = 0;
    }
    hitCount++;
    return containsCacheGeomPrep.contains(g2); 
  }
 
开发者ID:dr-jts,项目名称:jeql,代码行数:14,代码来源:GeomExpFunction.java


示例17: intersectionPrep

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public static Geometry intersectionPrep(Geometry g1, Geometry g2) 
{ 
  if (intersectionCacheGeom == null
      || intersectionCacheGeom != g1) {
    intersectionCacheGeom = g1;
    intersectionCacheGeomPrep = PreparedGeometryFactory.prepare(g1);
  }
  hitCount++;
  if (! intersectionCacheGeomPrep.intersects(g2))
    return g2.getFactory().createGeometryCollection(null);
  if (intersectionCacheGeomPrep.contains(g2))
    return g2;
  return g1.intersection(g2);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:15,代码来源:GeomExpFunction.java


示例18: prepare

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
/**
 * Creates a prepared geometry. <p> Prepared geometries make operations like intersection must faster. </p>
 */
public static PreparedGeometry prepare(Geometry g) {
  return PreparedGeometryFactory.prepare(g);
}
 
开发者ID:geomgis,项目名称:geogson,代码行数:7,代码来源:Geom.java


示例19: masked_by

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
@operator (
		value = "masked_by",
		category = { IOperatorCategory.SPATIAL },
		concept = { IConcept.GEOMETRY, IConcept.SPATIAL_COMPUTATION, IConcept.OBSTACLE })
@doc (
		examples = { @example (
				value = "perception_geom masked_by obstacle_list",
				equals = "the geometry representing the part of perception_geom visible from the agent position considering the list of obstacles obstacle_list.",
				isExecutable = false) })
public static IShape masked_by(final IScope scope, final IShape source, final IContainer<?, IShape> obstacles,
		Integer precision) {
	final IAgent a = scope.getAgent();
	final List<IShape> obst =
			obstacles == null ? new ArrayList<IShape>() : obstacles.listValue(scope, Types.GEOMETRY, false);
	final ILocation location = a != null ? a.getLocation() : new GamaPoint(0, 0);
	if (precision == null) {
		precision = 120;
	}
	final Geometry visiblePercept = GeometryUtils.GEOMETRY_FACTORY.createGeometry(source.getInnerGeometry());
	final boolean isPoint = source.isPoint();
	if (obstacles != null && !obstacles.isEmpty(scope)) {
		final Geometry pt = GeometryUtils.GEOMETRY_FACTORY.createPoint(GeometryUtils.toCoordinate(location));
		final Geometry locG = pt.buffer(0.01).getEnvelope();
		double percep_dist = 0;
		for (final ILocation p : source.getPoints()) {
			final double dist = location.euclidianDistanceTo(p);
			if (dist > percep_dist) {
				percep_dist = dist;
			}
		}
		final Geometry gbuff = pt.buffer(percep_dist, precision / 4);
		final List<IShape> geoms = new ArrayList<IShape>();
		for (int k = 1; k < gbuff.getNumPoints(); k++) {
			final IList coordinates = GamaListFactory.create(Types.POINT, 4);
			coordinates.add(location);
			coordinates.add(new GamaPoint(gbuff.getCoordinates()[k - 1]));
			coordinates.add(new GamaPoint(gbuff.getCoordinates()[k]));
			coordinates.add(location);
			final IShape gg =
					Spatial.Operators.inter(scope, source, Spatial.Creation.polygon(scope, coordinates));
			if (gg != null && (isPoint || !gg.isPoint())) {
				geoms.add(new GamaShape(gg));
			}
		}
		final GamaList geomsVisible = (GamaList) GamaListFactory.create();
		final PreparedGeometry ref = PreparedGeometryFactory.prepare(locG);

		for (final IShape geom : geoms) {
			if (!intersection(geom, obst)) {
				geomsVisible.addValue(scope, geom);
			} else {
				final IShape perceptReal = difference(scope, geom, obst, ref);

				if (perceptReal != null && (isPoint || !perceptReal.isPoint())) {
					geomsVisible.addValue(scope, perceptReal);
				}
			}
		}
		if (!geomsVisible.isEmpty(scope)) {
			IShape result = Cast.asGeometry(scope, geomsVisible, false);
			if (result.getInnerGeometry() instanceof GeometryCollection) {
				result = Spatial.Transformations.enlarged_by(scope, result, 0.1);
			}
			return result;
		}
		return null;
	}
	return new GamaShape(visiblePercept);
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:70,代码来源:Spatial.java


示例20: setup

import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; //导入依赖的package包/类
public void setup()
{
  Geometry sinePoly = createSineStar(new Coordinate(0, 0), 100000.0, nPts);
  pg = PreparedGeometryFactory.prepare(sinePoly);
  g = createSineStar(new Coordinate(10, 10), 100000.0, 100);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:7,代码来源:PreparedGeometryThreadSafeTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LocationSource类代码示例发布时间:2022-05-21
下一篇:
Java PropertyNotWritableException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap