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


Java WKTWriter类代码示例

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


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

示例1: checkMaximumDistance

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
/**
     * Checks that the furthest distance from the buffer curve to the input
     * is less than the given maximum distance.
     * This uses the Oriented Hausdorff distance metric.
     * It corresponds to finding
     * the point on the buffer curve which is furthest from <i>some</i> point on the input.
     *
     * @param input a geometry
     * @param bufCurve a geometry
     * @param maxDist the maximum distance that a buffer result can be from the input
     */
    private void checkMaximumDistance(Geometry input, Geometry bufCurve, double maxDist) {
//    BufferCurveMaximumDistanceFinder maxDistFinder = new BufferCurveMaximumDistanceFinder(input);
//    maxDistanceFound = maxDistFinder.findDistance(bufCurve);

        DiscreteHausdorffDistance haus = new DiscreteHausdorffDistance(bufCurve, input);
        haus.setDensifyFraction(0.25);
        this.maxDistanceFound = haus.orientedDistance();

        if (this.maxDistanceFound > maxDist) {
            this.isValid = false;
            Coordinate[] pts = haus.getCoordinates();
            this.errorLocation = pts[1];
            this.errorIndicator = input.getFactory().createLineString(pts);
            this.errMsg = "Distance between buffer curve and input is too large "
                    + "(" + this.maxDistanceFound
                    + " at " + WKTWriter.toLineString(pts[0], pts[1]) + ")";
        }
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:30,代码来源:BufferDistanceValidator.java

示例2: printDebugWKT

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
protected void printDebugWKT(Set<GeoHash> geoHashes) {
	final Set<Polygon> geometries = geoHashes
			.stream()
			.map(geoHash -> (Polygon) new GeoHash2Geometry(new WGS84Point2Coordinate()).apply(
					geoHash, new GeometryFactory()))
			.collect(toSet());
	System.out.println(geoHashes.stream()
			.map(GeoHash::toBase32)
			.map(hash -> "\"" + hash + "\"")
			.collect(toSet()));
	final Polygon[] polygons = geometries.toArray(new Polygon[geometries.size()]);
	final MultiPolygon multiPolygon = new GeometryFactory().createMultiPolygon(polygons);

	final WKTWriter wktWriter = new WKTWriter();
	System.out.println(wktWriter.write(multiPolygon));
}
 
开发者ID:adrianulbona,项目名称:jts-discretizer,代码行数:17,代码来源:GeometryDiscretizerTestBase.java

示例3: toSolrInputDocument

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
@Override
public SolrInputDocument toSolrInputDocument() {
	SolrInputDocument sid = super.toSolrInputDocument();
	sid.addField("searchable.label_sort", getTitle());
	//addField(sid,"place.fips_code_t", getFipsCode());
	StringBuilder summary = new StringBuilder().append(getTitle()).append(" ").append(getFipsCode());
	sid.addField("searchable.solrsummary_t", summary);
	if (getShape() != null) {
		try {
			WKTWriter wktWriter = new WKTWriter();
			sid.addField("geo", wktWriter
					.write(TopologyPreservingSimplifier.simplify(
							getShape(), 0.01)));
		} catch (Exception e) {
			logger.error(e.getLocalizedMessage());
		}
	}
	return sid;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:20,代码来源:Place.java

示例4: testSimplifyLevel4

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
@Test
@Ignore
public void testSimplifyLevel4() throws Exception {
	JtsSpatialContext ctx = new JtsSpatialContext(false);
	SampleDataReader sampleDataReader = new SampleDataReader(level4Resource.getInputStream());
	PrintWriter printWriter = new PrintWriter(new BufferedWriter(new FileWriter("level4_simplified.txt")));
	WKTReader wktreader = new WKTReader();
	WKTWriter wktwriter = new WKTWriter();

	while(sampleDataReader.hasNext()) {
		SampleData sampleData = sampleDataReader.next();

		Geometry geom = wktreader.read(sampleData.shape);
		if(!geom.isValid()) {
			logger.warn(sampleData.name + " is not valid");
		}

		printWriter.print(sampleData.id +"\t" + sampleData.code + "\t" + sampleData.name +"\t" + wktwriter.write(TopologyPreservingSimplifier.simplify(geom,0.2)) + "\n");

	}
	printWriter.flush();
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:23,代码来源:JtsGeometryTest.java

示例5: toSolrInputDocument

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
@Override
public SolrInputDocument toSolrInputDocument(ApplicationContext ctx) {
	SolrInputDocument sid = super.toSolrInputDocument();
	sid.addField("searchable.label_sort", getTitle());
	//addField(sid,"place.fips_code_t", getFipsCode());
	StringBuilder summary = new StringBuilder().append(getTitle()).append(" ").append(getFipsCode());
	sid.addField("searchable.solrsummary_t", summary.toString());
	if (getShape() != null) {
		try {
			WKTWriter wktWriter = new WKTWriter();
			sid.addField("geo", wktWriter
					.write(TopologyPreservingSimplifier.simplify(
							getShape(), 0.01)));
		} catch (Exception e) {
			logger.error(e.getLocalizedMessage());
		}
	}
	return sid;
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:20,代码来源:Place.java

示例6: testSimplifyLevel4

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
@Test
@Ignore
public void testSimplifyLevel4() throws Exception {
	JtsSpatialContextFactory factory = new JtsSpatialContextFactory();
	factory.geo = false;
	JtsSpatialContext ctx = new JtsSpatialContext(factory);
	SampleDataReader sampleDataReader = new SampleDataReader(level4Resource.getInputStream());
	PrintWriter printWriter = new PrintWriter(new BufferedWriter(new FileWriter("level4_simplified.txt")));
	WKTReader wktreader = new WKTReader();
	WKTWriter wktwriter = new WKTWriter();

	while(sampleDataReader.hasNext()) {
		SampleData sampleData = sampleDataReader.next();

		Geometry geom = wktreader.read(sampleData.shape);
		if(!geom.isValid()) {
			logger.warn(sampleData.name + " is not valid");
		}

		printWriter.print(sampleData.id +"\t" + sampleData.code + "\t" + sampleData.name +"\t" + wktwriter.write(TopologyPreservingSimplifier.simplify(geom,0.2)) + "\n");

	}
	printWriter.flush();
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:25,代码来源:JtsGeometryTest.java

示例7: iterateOverTriangles

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

示例8: readGeometry

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
@Override
public String readGeometry(Wrapper aRs, int aColumnIndex, Connection aConnection) throws SQLException {
    Object read = aRs instanceof ResultSet ? ((ResultSet) aRs).getObject(aColumnIndex) : ((CallableStatement) aRs).getObject(aColumnIndex);
    boolean wasNull = aRs instanceof ResultSet ? ((ResultSet) aRs).wasNull() : ((CallableStatement) aRs).wasNull();
    if (wasNull) {
        return null;
    } else {
        if (read instanceof STRUCT) {
            STRUCT struct = (STRUCT) read;
            GeometryConverter reader = new GeometryConverter(struct.getInternalConnection());
            Geometry geometry = reader.asGeometry(struct);
            WKTWriter writer = new WKTWriter();
            return writer.write(geometry);
        } else {
            return null;
        }
    }
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:19,代码来源:OracleSqlDriver.java

示例9: checkMinimumDistance

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
/**
 * Checks that two geometries are at least a minumum distance apart.
 *
 * @param g1      a geometry
 * @param g2      a geometry
 * @param minDist the minimum distance the geometries should be separated by
 */
private void checkMinimumDistance(Geometry g1, Geometry g2, double minDist) {
    DistanceOp distOp = new DistanceOp(g1, g2, minDist);
    minDistanceFound = distOp.distance();


    if (minDistanceFound < minDist) {
        isValid = false;
        Coordinate[] pts = distOp.nearestPoints();
        errorLocation = distOp.nearestPoints()[1];
        errorIndicator = g1.getFactory().createLineString(pts);
        errMsg = "Distance between buffer curve and input is too small "
                + "(" + minDistanceFound
                + " at " + WKTWriter.toLineString(pts[0], pts[1]) + " )";
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:23,代码来源:BufferDistanceValidator.java

示例10: checkMaximumDistance

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
/**
     * Checks that the furthest distance from the buffer curve to the input
     * is less than the given maximum distance.
     * This uses the Oriented Hausdorff distance metric.
     * It corresponds to finding
     * the point on the buffer curve which is furthest from <i>some</i> point on the input.
     *
     * @param input    a geometry
     * @param bufCurve a geometry
     * @param maxDist  the maximum distance that a buffer result can be from the input
     */
    private void checkMaximumDistance(Geometry input, Geometry bufCurve, double maxDist) {
//    BufferCurveMaximumDistanceFinder maxDistFinder = new BufferCurveMaximumDistanceFinder(input);
//    maxDistanceFound = maxDistFinder.findDistance(bufCurve);

        DiscreteHausdorffDistance haus = new DiscreteHausdorffDistance(bufCurve, input);
        haus.setDensifyFraction(0.25);
        maxDistanceFound = haus.orientedDistance();

        if (maxDistanceFound > maxDist) {
            isValid = false;
            Coordinate[] pts = haus.getCoordinates();
            errorLocation = pts[1];
            errorIndicator = input.getFactory().createLineString(pts);
            errMsg = "Distance between buffer curve and input is too large "
                    + "(" + maxDistanceFound
                    + " at " + WKTWriter.toLineString(pts[0], pts[1]) + ")";
        }
    }
 
开发者ID:Semantive,项目名称:jts,代码行数:30,代码来源:BufferDistanceValidator.java

示例11: createSimpleCSV

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
public static void createSimpleCSV(GeometryImage glayer, String file,boolean append) throws IOException {
FileWriter fw = new FileWriter(file,append);
try{
       if(!append)
       	fw.append("geom," + glayer.getSchema(',') + "\n");
       WKTWriter wkt = new WKTWriter();
       for (Geometry geom : glayer.getGeometries()) {
           fw.append("\"" + wkt.writeFormatted(geom) + "\",");
           AttributesGeometry att = glayer.getAttributes(geom);
           if (att == null || att.getSchema().length==0) {
               fw.append("\n");
               continue;
           }
           for (int i = 0; i < att.getSchema().length; i++) {
               String key = att.getSchema()[i];
               fw.append(att.get(key) + "");
               if (i < att.getSchema().length - 1) {
                   fw.append(",");
               } else {
                   fw.append("\n");
               }
           }
       }
}finally{    
	fw.flush();
	fw.close();
}	
  }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:29,代码来源:GenericCSVIO.java

示例12: createCategoriesStatement

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
private PreparedStatement createCategoriesStatement(LocationsRequest request, Connection conn) throws Exception 
{
	String cmdFilter = buildSearchFilter("", request.getSearchFilter()); 

	Geometry geom = request.getGeometry();
	Envelope bbox = request.getBBox();
	if (bbox != null)
		cmdFilter += buildBboxFilter(bbox) + (geom == null ? "" : " AND ");

	if (geom != null)
	{
		if (geom instanceof Point)
		{
			Point p = (Point)geom;
			cmdFilter += String.format("GEOGRAPHY_WITHIN_DISTANCE(%s, GEOGRAPHY_POINT(%.7f, %.7f), %.1f)", _geomColumn, p.getCoordinate().x, p.getCoordinate().y, request.getRadius());
		} 
		else 
		{
			WKTWriter wktWriter = new WKTWriter();
			cmdFilter += String.format("GEOGRAPHY_WITHIN_DISTANCE(%s, \"%s\", %.1f)", _geomColumn, wktWriter.write(geom), request.getRadius());
		}
	}

	if (cmdFilter != "")
		cmdFilter = " WHERE " + cmdFilter;

	String stateText = _categoriesQuery.replace("!where_clause!", cmdFilter);

	return conn.prepareStatement(stateText);    
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:31,代码来源:MemSQLLocationsDataProvider.java

示例13: checkMinimumDistance

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
/**
 * Checks that two geometries are at least a minumum distance apart.
 *
 * @param g1 a geometry
 * @param g2 a geometry
 * @param minDist the minimum distance the geometries should be separated by
 */
private void checkMinimumDistance(Geometry g1, Geometry g2, double minDist) {
    DistanceOp distOp = new DistanceOp(g1, g2, minDist);
    this.minDistanceFound = distOp.distance();

    if (this.minDistanceFound < minDist) {
        this.isValid = false;
        Coordinate[] pts = distOp.nearestPoints();
        this.errorLocation = distOp.nearestPoints()[1];
        this.errorIndicator = g1.getFactory().createLineString(pts);
        this.errMsg = "Distance between buffer curve and input is too small "
                + "(" + this.minDistanceFound
                + " at " + WKTWriter.toLineString(pts[0], pts[1]) + " )";
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:22,代码来源:BufferDistanceValidator.java

示例14: checkRobustInCircle

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
/**
 * Checks if the computed value for isInCircle is correct, using
 * double-double precision arithmetic.
 *
 * @param a a vertex of the triangle
 * @param b a vertex of the triangle
 * @param c a vertex of the triangle
 * @param p the point to test
 */
private static void checkRobustInCircle(Coordinate a, Coordinate b, Coordinate c,
                                        Coordinate p) {
    boolean nonRobustInCircle = isInCircleNonRobust(a, b, c, p);
    boolean isInCircleDD = TrianglePredicate.isInCircleDDSlow(a, b, c, p);
    boolean isInCircleCC = TrianglePredicate.isInCircleCC(a, b, c, p);

    Coordinate circumCentre = Triangle.circumcentre(a, b, c);
    System.out.println("p radius diff a = "
            + Math.abs(p.distance(circumCentre) - a.distance(circumCentre))
            / a.distance(circumCentre));

    if (nonRobustInCircle != isInCircleDD || nonRobustInCircle != isInCircleCC) {
        System.out.println("inCircle robustness failure (double result = "
                + nonRobustInCircle
                + ", DD result = " + isInCircleDD
                + ", CC result = " + isInCircleCC + ")");
        System.out.println(WKTWriter.toLineString(new CoordinateArraySequence(
                new Coordinate[] { a, b, c, p })));
        System.out.println("Circumcentre = " + WKTWriter.toPoint(circumCentre)
                + " radius = " + a.distance(circumCentre));
        System.out.println("p radius diff a = "
                + Math.abs(p.distance(circumCentre) / a.distance(circumCentre) - 1));
        System.out.println("p radius diff b = "
                + Math.abs(p.distance(circumCentre) / b.distance(circumCentre) - 1));
        System.out.println("p radius diff c = "
                + Math.abs(p.distance(circumCentre) / c.distance(circumCentre) - 1));
        System.out.println();
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:39,代码来源:TrianglePredicate.java

示例15: checkTriangleSize

import com.vividsolutions.jts.io.WKTWriter; //导入依赖的package包/类
private void checkTriangleSize(Coordinate[] pts) {
    String loc = "";
    if (pts.length >= 2) {
        loc = WKTWriter.toLineString(pts[0], pts[1]);
    } else {
        if (pts.length >= 1) {
            loc = WKTWriter.toPoint(pts[0]);
        }
    }
    // Assert.isTrue(pts.length == 4, "Too few points for visited triangle at " + loc);
    //com.vividsolutions.jts.util.Debug.println("too few points for triangle at " + loc);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:13,代码来源:QuadEdgeSubdivision.java


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