當前位置: 首頁>>代碼示例>>Java>>正文


Java PrecisionModel類代碼示例

本文整理匯總了Java中com.vividsolutions.jts.geom.PrecisionModel的典型用法代碼示例。如果您正苦於以下問題:Java PrecisionModel類的具體用法?Java PrecisionModel怎麽用?Java PrecisionModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PrecisionModel類屬於com.vividsolutions.jts.geom包,在下文中一共展示了PrecisionModel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convert

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
private static void convert(String inputFile, String outputFile) {
	ODLDatastoreAlterable<ODLTableAlterable> tables = TableIOUtils.importFile(new File(inputFile), ImportFileType.SHAPEFILE_COPIED_GEOM, null,null);
	
	ODLTable table = tables.getTableAt(0);
	
	// by default use 6 digit precision
	GeometryFactory factory = new GeometryFactory(new PrecisionModel(100000));
	for(int col =0 ; col< table.getColumnCount() ; col++){
		if(table.getColumnType(col)==ODLColumnType.GEOM){
			for(int row=0;row < table.getRowCount(); row++){
				ODLGeomImpl geom = (ODLGeomImpl)table.getValueAt(row, col);
				if(geom!=null){
					// take down precision
					Geometry geometry =geom.getJTSGeometry();
					geometry = factory.createGeometry(geometry);
					
					// set back
					ODLLoadedGeometry loadedGeometry = new ODLLoadedGeometry(geometry);
					table.setValueAt(loadedGeometry,row, col);
				}
			}
		}
	}
	TableIOUtils.writeToTabFile(table, new File(outputFile));
}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:26,代碼來源:Shapefile2TextCommand.java

示例2: getShape

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
private Geometry getShape(CSVRecord record) {
    if (!config.getGeographyProjection().equals("") &&
            config.getGeographyXIndex() != -1 &&
            config.getGeographyYIndex() != -1) {

        GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), Subject.SRID);

        Coordinate coordinate = null;
        Double x = Double.parseDouble(record.get(config.getGeographyXIndex()));
        Double y = Double.parseDouble(record.get(config.getGeographyYIndex()));
        if (config.getGeographyProjection().equals(CoordinateUtils.WGS84CRS)) {

            coordinate = new Coordinate(x, y);
        } else {
            try {
                coordinate = CoordinateUtils.eastNorthToLatLong(x, y, config.getGeographyProjection(), CoordinateUtils.WGS84CRS);
            } catch (Exception e) {
                log.warn("Coordinates will not be considered: " + e.getMessage());
                return null;
            }
        }
        return geometryFactory.createPoint(coordinate);
    }

    return null;
}
 
開發者ID:FutureCitiesCatapult,項目名稱:TomboloDigitalConnector,代碼行數:27,代碼來源:GeneralCSVImporter.java

示例3: computeOverlaySnapTolerance

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
/**
 * Estimates the snap tolerance for a Geometry, taking into account its precision model.
 *
 * @param g a Geometry
 * @return the estimated snap tolerance
 */
public static double computeOverlaySnapTolerance(Geometry g) {
    double snapTolerance = computeSizeBasedSnapTolerance(g);

    /**
     * Overlay is carried out in the precision model
     * of the two inputs.
     * If this precision model is of type FIXED, then the snap tolerance
     * must reflect the precision grid size.
     * Specifically, the snap tolerance should be at least
     * the distance from a corner of a precision grid cell
     * to the centre point of the cell.
     */
    PrecisionModel pm = g.getPrecisionModel();
    if (pm.getType() == PrecisionModel.FIXED) {
        double fixedSnapTol = (1 / pm.getScale()) * 2 / 1.415;
        if (fixedSnapTol > snapTolerance) {
            snapTolerance = fixedSnapTol;
        }
    }
    return snapTolerance;
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:28,代碼來源:GeometrySnapper.java

示例4: getNoder

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
private Noder getNoder(PrecisionModel precisionModel) {
        if (this.workingNoder != null) {
            return this.workingNoder;
        }

        // otherwise use a fast (but non-robust) noder
        MCIndexNoder noder = new MCIndexNoder();
        LineIntersector li = new RobustLineIntersector();
        li.setPrecisionModel(precisionModel);
        noder.setSegmentIntersector(new IntersectionAdder(li));
//    Noder noder = new IteratedNoder(precisionModel);
        return noder;
//    Noder noder = new SimpleSnapRounder(precisionModel);
//    Noder noder = new MCIndexSnapRounder(precisionModel);
//    Noder noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)),
//                                  precisionModel.getScale());
    }
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:18,代碼來源:BufferBuilder.java

示例5: computeNodedEdges

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
private void computeNodedEdges(List bufferSegStrList, PrecisionModel precisionModel) {
        Noder noder = this.getNoder(precisionModel);
        noder.computeNodes(bufferSegStrList);
        Collection nodedSegStrings = noder.getNodedSubstrings();
// DEBUGGING ONLY
//BufferDebug.saveEdges(nodedEdges, "run" + BufferDebug.runCount + "_nodedEdges");

        for (Object nodedSegString : nodedSegStrings) {
            SegmentString segStr = (SegmentString) nodedSegString;

            /**
             * Discard edges which have zero length,
             * since they carry no information and cause problems with topology building
             */
            Coordinate[] pts = segStr.getCoordinates();
            if (pts.length == 2 && pts[0].equals2D(pts[1])) {
                continue;
            }

            Label oldLabel = (Label) segStr.getData();
            Edge edge = new Edge(segStr.getCoordinates(), new Label(oldLabel));
            this.insertUniqueEdge(edge);
        }
        //saveEdges(edgeList.getEdges(), "run" + runCount + "_collapsedEdges");
    }
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:26,代碼來源:BufferBuilder.java

示例6: OffsetSegmentGenerator

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
public OffsetSegmentGenerator(PrecisionModel precisionModel,
                              BufferParameters bufParams, double distance) {
    this.precisionModel = precisionModel;
    this.bufParams = bufParams;

    // compute intersections in full precision, to provide accuracy
    // the points are rounded as they are inserted into the curve line
    this.li = new RobustLineIntersector();
    this.filletAngleQuantum = Math.PI / 2.0 / bufParams.getQuadrantSegments();

    /**
     * Non-round joins cause issues with short closing segments, so don't use
     * them. In any case, non-round joins only really make sense for relatively
     * small buffer distances.
     */
    if (bufParams.getQuadrantSegments() >= 8
            && bufParams.getJoinStyle() == BufferParameters.JOIN_ROUND) {
        this.closingSegLengthFactor = MAX_CLOSING_SEG_LEN_FACTOR;
    }
    this.init(distance);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:22,代碼來源:OffsetSegmentGenerator.java

示例7: densifyPoints

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
/**
 * Densifies a coordinate sequence.
 *
 * @param pts
 * @param distanceTolerance
 * @return the densified coordinate sequence
 */
private static Coordinate[] densifyPoints(Coordinate[] pts,
                                          double distanceTolerance, PrecisionModel precModel) {
    LineSegment seg = new LineSegment();
    CoordinateList coordList = new CoordinateList();
    for (int i = 0; i < pts.length - 1; i++) {
        seg.p0 = pts[i];
        seg.p1 = pts[i + 1];
        coordList.add(seg.p0, false);
        double len = seg.getLength();
        int densifiedSegCount = (int) (len / distanceTolerance) + 1;
        if (densifiedSegCount > 1) {
            double densifiedSegLen = len / densifiedSegCount;
            for (int j = 1; j < densifiedSegCount; j++) {
                double segFract = (j * densifiedSegLen) / len;
                Coordinate p = seg.pointAlong(segFract);
                precModel.makePrecise(p);
                coordList.add(p, false);
            }
        }
    }
    coordList.add(pts[pts.length - 1], false);
    return coordList.toCoordinateArray();
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:31,代碼來源:Densifier.java

示例8: wktToGeometry

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
public static Geometry wktToGeometry(String lat, String lon, SpatialType spatialType) {

		//VT: spatial store in lon/lat however mapping framework are often in lat/lon
		//http://postgis.net/2013/08/18/tip_lon_lat/
		String wkt="";
		if(spatialType == SpatialType.POINT){
			 wkt = String.format("Point(%s %s)", lon,lat);
		}
				
        WKTReader fromText = new WKTReader(new GeometryFactory(new PrecisionModel(),4326));
        Geometry geom = null;
        try {
            geom = fromText.read(wkt);                        
        } catch (Exception e) {
            return null;
        }
        return geom;
    }
 
開發者ID:AuScope,項目名稱:IGSN,代碼行數:19,代碼來源:SpatialUtilities.java

示例9: withPrecision

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
@operator (
		value = "with_precision",
		category = { IOperatorCategory.SPATIAL, IOperatorCategory.SP_TRANSFORMATIONS },
		concept = { IConcept.GEOMETRY, IConcept.SPATIAL_COMPUTATION, IConcept.SPATIAL_TRANSFORMATION })
@doc (
		value = "A geometry corresponding to the rounding of points of the operand considering a given precison.",
		examples = { @example (
				value = "self with_precision 2",
				equals = "the geometry resulting from the rounding of points of the geometry with a precision of 0.1.",
				test = false) })
public static IShape withPrecision(final IScope scope, final IShape g1, final Integer precision) {
	if (g1 == null || g1.getInnerGeometry() == null) { return g1; }
	final double scale = Math.pow(10, precision);
	final PrecisionModel pm = new PrecisionModel(scale);
	return new GamaShape(GeometryPrecisionReducer.reduce(g1.getInnerGeometry(), pm));
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:17,代碼來源:Spatial.java

示例10: PolygonUnion

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
/**
 * Polygon union.
 *
 * @return the polygon
 */
public Polygon PolygonUnion() {
	Polygon result = this.rawSpatialRDD.reduce(new Function2<Polygon, Polygon, Polygon>() {
        public Polygon call(Polygon v1, Polygon v2) {
            //Reduce precision in JTS to avoid TopologyException
            PrecisionModel pModel = new PrecisionModel();
            GeometryPrecisionReducer pReducer = new GeometryPrecisionReducer(pModel);
            Geometry p1 = pReducer.reduce(v1);
            Geometry p2 = pReducer.reduce(v2);
            //Union two polygons
            Geometry polygonGeom = p1.union(p2);
            Coordinate[] coordinates = polygonGeom.getCoordinates();
            ArrayList<Coordinate> coordinateList = new ArrayList<Coordinate>(Arrays.asList(coordinates));
            Coordinate lastCoordinate = coordinateList.get(0);
            coordinateList.add(lastCoordinate);
            Coordinate[] coordinatesClosed = new Coordinate[coordinateList.size()];
            coordinatesClosed = coordinateList.toArray(coordinatesClosed);
            GeometryFactory fact = new GeometryFactory();
            LinearRing linear = new GeometryFactory().createLinearRing(coordinatesClosed);
            Polygon polygon = new Polygon(linear, null, fact);
            //Return the two polygon union result
            return polygon;
        }
    });
    return result;
}
 
開發者ID:DataSystemsLab,項目名稱:GeoSpark,代碼行數:31,代碼來源:PolygonRDD.java

示例11: OffsetSegmentGenerator

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
public OffsetSegmentGenerator(PrecisionModel precisionModel,
                              BufferParameters bufParams, double distance) {
    this.precisionModel = precisionModel;
    this.bufParams = bufParams;

    // compute intersections in full precision, to provide accuracy
    // the points are rounded as they are inserted into the curve line
    li = new RobustLineIntersector();
    filletAngleQuantum = Math.PI / 2.0 / bufParams.getQuadrantSegments();

    /**
     * Non-round joins cause issues with short closing segments, so don't use
     * them. In any case, non-round joins only really make sense for relatively
     * small buffer distances.
     */
    if (bufParams.getQuadrantSegments() >= 8
            && bufParams.getJoinStyle() == BufferParameters.JOIN_ROUND)
        closingSegLengthFactor = MAX_CLOSING_SEG_LEN_FACTOR;
    init(distance);
}
 
開發者ID:Semantive,項目名稱:jts,代碼行數:21,代碼來源:OffsetSegmentGenerator.java

示例12: CurveBuilder

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
public CurveBuilder() {
	BufferParameters bufferParameters = new BufferParameters();
	bufferParameters.setEndCapStyle(BufferParameters.CAP_FLAT);
	bufferParameters.setJoinStyle(BufferParameters.JOIN_ROUND);

	/*
	 * Sets the number of line segments used to approximate an angle fillet.
	 * 
	 *   If quadSegs >= 1, joins are round, and quadSegs indicates the number of segments to use to approximate a quarter-circle.
   	 *   If quadSegs = 0, joins are bevelled (flat)
        *   If quadSegs < 0, joins are mitred, and the value of qs indicates the mitre ration limit as
        *       mitreLimit = |quadSegs|
        *
        * For round joins, quadSegs determines the maximum error in the approximation to the true buffer curve. 
        * The default value of 8 gives less than 2% max error in the buffer distance. For a max error of < 1%, 
        * use QS = 12. For a max error of < 0.1%, use QS = 18. The error is always less than the buffer distance 
        * (in other words, the computed buffer curve is always inside the true curve). 
	 */
	bufferParameters.setQuadrantSegments(18);
	
	this.curveBuilder = new OffsetCurveBuilder(new PrecisionModel(), bufferParameters);
}
 
開發者ID:geops,項目名稱:trafimage-geoserver-transformations,代碼行數:23,代碼來源:CurveBuilder.java

示例13: OffsetSegmentGenerator

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
public OffsetSegmentGenerator(PrecisionModel precisionModel,
    BufferParameters bufParams, double distance) {
  this.precisionModel = precisionModel;
  this.bufParams = bufParams;

  // compute intersections in full precision, to provide accuracy
  // the points are rounded as they are inserted into the curve line
  li = new RobustLineIntersector();
  filletAngleQuantum = Math.PI / 2.0 / bufParams.getQuadrantSegments();

  /**
   * Non-round joins cause issues with short closing segments, so don't use
   * them. In any case, non-round joins only really make sense for relatively
   * small buffer distances.
   */
  if (bufParams.getQuadrantSegments() >= 8
      && bufParams.getJoinStyle() == BufferParameters.JOIN_ROUND)
    closingSegLengthFactor = MAX_CLOSING_SEG_LEN_FACTOR;
  init(distance);
}
 
開發者ID:GitHubDroid,項目名稱:geodroid_master_update,代碼行數:21,代碼來源:OffsetSegmentGenerator.java

示例14: convert

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
@Override
public DistributableQuery convert(
		final Serializable ob )
		throws Exception {
	if (ob instanceof byte[]) {
		return (DistributableQuery) PropertyManagement.fromBytes((byte[]) ob);
	}
	final PrecisionModel precision = new PrecisionModel();
	final GeometryFactory geometryFactory = new GeometryFactory(
			precision,
			4326);
	final WKTReader wktReader = new WKTReader(
			geometryFactory);
	return new SpatialQuery(
			wktReader.read(ob.toString()));
}
 
開發者ID:locationtech,項目名稱:geowave,代碼行數:17,代碼來源:PropertyManagement.java

示例15: GwtMultiLineStringTest

import com.vividsolutions.jts.geom.PrecisionModel; //導入依賴的package包/類
public GwtMultiLineStringTest() {
	gwtFactory = new GeometryFactory(SRID, PRECISION);
	LineString gwtLine1 = gwtFactory.createLineString(new Coordinate[] {new Coordinate(10.0, 10.0),
			new Coordinate(20.0, 10.0), new Coordinate(20.0, 20.0)});
	LineString gwtLine2 = gwtFactory.createLineString(new Coordinate[] {new Coordinate(10.0, 20.0),
			new Coordinate(30.0, 10.0), new Coordinate(40.0, 10.0)});
	gwt = gwtFactory.createMultiLineString(new LineString[] {gwtLine1, gwtLine2});

	jtsFactory = new com.vividsolutions.jts.geom.GeometryFactory(new PrecisionModel(), SRID);
	com.vividsolutions.jts.geom.LineString jtsLine1 = jtsFactory
			.createLineString(new com.vividsolutions.jts.geom.Coordinate[] {
					new com.vividsolutions.jts.geom.Coordinate(10.0, 10.0),
					new com.vividsolutions.jts.geom.Coordinate(20.0, 10.0),
					new com.vividsolutions.jts.geom.Coordinate(20.0, 20.0)});
	com.vividsolutions.jts.geom.LineString jtsLine2 = jtsFactory
			.createLineString(new com.vividsolutions.jts.geom.Coordinate[] {
					new com.vividsolutions.jts.geom.Coordinate(10.0, 20.0),
					new com.vividsolutions.jts.geom.Coordinate(30.0, 10.0),
					new com.vividsolutions.jts.geom.Coordinate(40.0, 10.0)});
	jts = jtsFactory.createMultiLineString(new com.vividsolutions.jts.geom.LineString[] {jtsLine1, jtsLine2});
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt,代碼行數:22,代碼來源:GwtMultiLineStringTest.java


注:本文中的com.vividsolutions.jts.geom.PrecisionModel類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。