private void ComputeOrientedDistance(IGeometry discreteGeom, IGeometry geom, PointPairDistance ptDist) { var distFilter = new MaxPointDistanceFilter(geom); discreteGeom.Apply(distFilter); ptDist.SetMaximum(distFilter.MaxPointDistance); if (_densifyFrac > 0) { var fracFilter = new MaxDensifiedByFractionDistanceFilter(geom, _densifyFrac); discreteGeom.Apply(fracFilter); ptDist.SetMaximum(fracFilter.MaxPointDistance); } }
/// <summary> /// Extracts the linear components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>LineExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom">The point from which to extract linear components.</param> /// <returns>The list of linear components.</returns> public static IList GetLines(IGeometry geom) { IList lines = new ArrayList(); geom.Apply(new LinearComponentExtracter(lines)); return(lines); }
/// <summary> /// Returns a list containing a point from each Polygon, LineString, and Point /// found inside the specified point. Thus, if the specified point is /// not a GeometryCollection, an empty list will be returned. The elements of the list /// are <c>com.vividsolutions.jts.operation.distance.GeometryLocation</c>s. /// </summary> public static IList <GeometryLocation> GetLocations(IGeometry geom) { var locations = new List <GeometryLocation>(); geom.Apply(new ConnectedElementLocationFilter(locations)); return(locations); }
/// <summary> /// Extracts the linear components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>LineExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom">The point from which to extract linear components.</param> /// <returns>The list of linear components.</returns> public static ICollection <IGeometry> GetLines(IGeometry geom) { Collection <IGeometry> lines = new Collection <IGeometry>(); geom.Apply(new LinearComponentExtracter(lines)); return(lines); }
private void computeMaxMidpointDistance(IGeometry curve) { MaxMidpointDistanceFilter distFilter = new MaxMidpointDistanceFilter(_inputGeom); curve.Apply(distFilter); _maxPtDist.SetMaximum(distFilter.MaxPointDistance); }
public void Filter(IGeometry geom) { if (geom is IPoint) { return; } if (geom is ILineString) { geom.Apply(new SpikeFixSequenceFilter(_spikeThreshold)); } if (geom is IPolygon) { var poly = (IPolygon)geom; poly.ExteriorRing.Apply(new SpikeFixSequenceFilter(_spikeThreshold)); for (int i = 0; i < poly.NumInteriorRings; i++) { poly.GetInteriorRingN(i).Apply(new SpikeFixSequenceFilter(_spikeThreshold)); } } if (geom is IGeometryCollection) { for (int i = 0; i < geom.NumGeometries; i++) { geom.GetGeometryN(i).Apply(new SpikeFixFilter(_spikeThreshold)); } } }
/// <summary> /// Returns the Polygon components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>PolygonExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom"></param> public static IList GetPolygons(IGeometry geom) { IList comps = new ArrayList(); geom.Apply(new PolygonExtracter(comps)); return(comps); }
/// <summary> /// Adds the common coordinate bits back into a Geometry. /// The coordinates of the Geometry are changed. /// </summary> /// <param name="geom">The Geometry to which to add the common coordinate bits.</param> public virtual void AddCommonBits(IGeometry geom) { Translater trans = new Translater(_commonCoord); geom.Apply(trans); geom.GeometryChanged(); }
///<summary> /// Extracts the linear components from a single geometry. /// If more than one geometry is to be processed, it is more /// efficient to create a single <see cref="ComponentCoordinateExtracter"/> instance /// and pass it to multiple geometries. ///</summary> /// <param name="geom">The Geometry from which to extract</param> /// <returns>A list of Coordinates</returns> public static List <Coordinate> GetCoordinates(IGeometry geom) { var coords = new List <Coordinate>(); geom.Apply(new ComponentCoordinateExtracter(coords)); return(coords); }
/// <summary> /// Returns the Point components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>PointExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom"></param> public static IList GetPoints(IGeometry geom) { IList pts = new ArrayList(); geom.Apply(new PointExtracter(pts)); return(pts); }
/// <summary> /// Extracts the linear components from a single geometry. /// If more than one geometry is to be processed, it is more /// efficient to create a single <see cref="LinearComponentExtracter"/> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom">The geometry from which to extract linear components</param> /// <param name="forceToLineString"><c>true</c> if <see cref="ILinearRing"/>s should be converted to <see cref="ILineString"/>s</param> /// <returns>The list of linear components</returns> public static ICollection <IGeometry> GetLines(IGeometry geom, bool forceToLineString) { Collection <IGeometry> lines = new Collection <IGeometry>(); geom.Apply(new LinearComponentExtracter(lines, forceToLineString)); return(lines); }
/// <summary> /// Returns a list containing a point from each Polygon, LineString, and Point /// found inside the specified point. Thus, if the specified point is /// not a GeometryCollection, an empty list will be returned. The elements of the list /// are <c>com.vividsolutions.jts.operation.distance.GeometryLocation</c>s. /// </summary> public static IList GetLocations(IGeometry geom) { IList locations = new ArrayList(); geom.Apply(new ConnectedElementLocationFilter(locations)); return(locations); }
///<summary> /// Extracts linework for polygonal components. ///</summary> ///<param name="g">The geometry from which to extract</param> ///<returns>A lineal geometry containing the extracted linework</returns> private static IMultiLineString ExtractLinework(IGeometry g) { PolygonalLineworkExtracter extracter = new PolygonalLineworkExtracter(); g.Apply(extracter); List<ILineString> linework = extracter.Linework; return g.Factory.CreateMultiLineString(linework.ToArray()); }
/// <summary> /// Cretaes a new <see cref="IGeometry"/> which is the result of this transformation applied to the input Geometry. /// </summary> /// <param name="g">A <c>Geometry</c></param> /// <returns>The transformed Geometry</returns> public IGeometry Transform(IGeometry g) { IGeometry g2 = (IGeometry)g.Clone(); g2.Apply(this); return(g2); }
/// <summary> /// /// </summary> /// <param name="geom"></param> /// <returns></returns> private static ICoordinate[] ExtractCoordinates(IGeometry geom) { UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter(); geom.Apply(filter); return(filter.Coordinates); }
public static IGeometry GetPolygonHoles(IGeometry geom) { IList <IGeometry> holePolys = new List <IGeometry>(); geom.Apply(new InternalGeometryFilterImpl(holePolys)); return(geom.Factory.BuildGeometry(holePolys)); }
public static IGeometry ConvertGCSWGS84ToGoogleMercator(IGeometry geometry) { ICoordinateFilter filter = new GCSWGS84ToGoogleMercatorCoordinateFilter(); geometry.Apply(filter); return(geometry); }
/// <summary> /// Adds a <see cref="IGeometry"/> to be dissolved. /// Any number of geometries may be adde by calling this method multiple times. /// Any type of Geometry may be added. The constituent linework will be /// extracted to be dissolved. /// </summary> /// <param name="geometry">geometry to be line-merged</param> public void Add(IGeometry geometry) { geometry.Apply(new GeometryComponentFilter(c => { if (c is ILineString) Add(c as ILineString); })); }
public static void ConvertToGCSWGS84(IGeometry geometry) { ICoordinateFilter filter = new GCSWGS84CoordinateFilter(); (filter as GCSWGS84CoordinateFilter).Projection = getWellKnownTextProjection(geometry.SRID); geometry.Apply(filter); geometry.SRID = ProjectionUtil.GCS_WGS84_SRID; }
private static void ShiftGeomByX(IGeometry geom, int xShift) { if (xShift == 0) { return; } geom.Apply(new S4nCoordinateSequenceFilter(xShift)); }
public static void ConvertToGCSWGS84(IGeometry geometry, String wktProjection) { ICoordinateFilter filter = new GCSWGS84CoordinateFilter(); (filter as GCSWGS84CoordinateFilter).Projection = wktProjection; geometry.Apply(filter); geometry.SRID = ProjectionUtil.GCS_WGS84_SRID; }
///<summary> /// Extracts linework for polygonal components. ///</summary> ///<param name="g">The geometry from which to extract</param> ///<returns>A lineal geometry containing the extracted linework</returns> private static IMultiLineString ExtractLinework(IGeometry g) { var extracter = new PolygonalLineworkExtracter(); g.Apply(extracter); var linework = extracter.Linework; return(g.Factory.CreateMultiLineString(linework.ToArray())); }
public static IGeometry ConvertGCSWGS84ToNorthAmericanAlbersEqualArea(IGeometry geometry) { ICoordinateFilter filter = new GCSWGS84ToNAAlbersEqualAreaCoordinateFilter(); geometry.Apply(filter); geometry.SRID = NORTH_AMERICAN_ALBERS_EQUAL_AREA_SRID; return(geometry); }
public void TestInvalidateEnvelope() { IGeometry g = reader.Read("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))"); Assert.AreEqual(new Envelope(0, 50, 0, 50), g.EnvelopeInternal); g.Apply(new CoordinateFilter()); Assert.AreEqual(new Envelope(0, 50, 0, 50), g.EnvelopeInternal); g.GeometryChanged(); Assert.AreEqual(new Envelope(1, 51, 1, 51), g.EnvelopeInternal); }
/// <summary> /// Adds a <see cref="IGeometry"/> to be dissolved. /// Any number of geometries may be adde by calling this method multiple times. /// Any type of Geometry may be added. The constituent linework will be /// extracted to be dissolved. /// </summary> /// <param name="geometry">geometry to be line-merged</param> public void Add(IGeometry geometry) { geometry.Apply(new GeometryComponentFilter(c => { if (c is ILineString) { Add(c as ILineString); } })); }
protected IGeometry Rotate(IGeometry geom) { if (_rotationAngle != 0.0) { var centre = _dim.Centre; var trans = AffineTransformation.RotationInstance(_rotationAngle, centre.X, centre.Y); geom.Apply(trans); } return(geom); }
/// <summary> /// If <paramref name="geom"/> spans the dateline, then this modifies it to be a /// valid NTS geometry that extends to the right of the standard -180 to +180 /// width such that some points are greater than +180 but some remain less. /// Takes care to invoke <see cref="IGeometry.GeometryChanged()"/> /// if needed. /// </summary> /// <param name="geom"></param> /// <returns>The number of times the geometry spans the dateline. >= 0</returns> private static int UnwrapDateline(IGeometry geom) { if (geom.EnvelopeInternal.Width < 180) { return(0); //can't possibly cross the dateline } int[] crossings = { 0 }; //an array so that an inner class can modify it. geom.Apply(new S4nGeometryFilter(crossings)); return(crossings[0]); }
private NtsGeometry ShiftPoly(NtsGeometry poly, int lon_shift) { IGeometry pGeom = poly.Geometry; Assert.True(pGeom.IsValid); //shift 180 to the right pGeom = (IGeometry)pGeom.Clone(); pGeom.Apply(new CoordinateFilterAnonymousHelper(this, lon_shift)); pGeom.GeometryChanged(); Assert.False(pGeom.IsValid); return((NtsGeometry)ctx.ReadShapeFromWkt(pGeom.AsText())); }
/// <summary> /// Removes the common coordinate bits from a Geometry. /// The coordinates of the Geometry are changed. /// </summary> /// <param name="geom">The Geometry from which to remove the common coordinate bits.</param> /// <returns>The shifted Geometry.</returns> public IGeometry RemoveCommonBits(IGeometry geom) { if (commonCoord.X == 0.0 && commonCoord.Y == 0.0) return geom; ICoordinate invCoord = new Coordinate(commonCoord); invCoord.X = -invCoord.X; invCoord.Y = -invCoord.Y; Translater trans = new Translater(invCoord); geom.Apply(trans); geom.GeometryChanged(); return geom; }
/// <summary> /// Extracts the linear components from a single <see cref="IGeometry"/> /// and adds them to the provided <see cref="ICollection{ILineString}"/>. /// </summary> /// <param name="geom">The geometry from which to extract linear components</param> /// <param name="lines">The Collection to add the extracted linear components to</param> /// <returns>The Collection of linear components (LineStrings or LinearRings)</returns> public static ICollection <IGeometry> GetLines(IGeometry geom, ICollection <IGeometry> lines) { if (geom is ILineString) { lines.Add(geom); } else { geom.Apply(new LinearComponentExtracter(lines)); } return(lines); }
/// <summary> /// Extracts the linear components from a single <see cref="IGeometry"/> /// and adds them to the provided <see cref="ICollection{ILineString}"/>. /// </summary> /// <param name="geom">The geometry from which to extract linear components</param> /// <param name="lines">The Collection to add the extracted linear components to</param> /// <returns>The Collection of linear components (LineStrings or LinearRings)</returns> public static ICollection<IGeometry> GetLines(IGeometry geom, ICollection<IGeometry> lines) { if (geom is ILineString) { lines.Add(geom); } else { geom.Apply(new LinearComponentExtracter(lines)); } return lines; }
/// <summary> /// Extracts the <see cref="ILineString"/> elements from a single <see cref="IGeometry"/> /// and adds them to the<see cref="List{ILineString}"/>. /// </summary> /// <param name="geom">The geometry from which to extract</param> /// <param name="lines">The list to add the extracted elements to</param> /// <returns>The <paramref name="lines"/> list argument</returns> public static ICollection <IGeometry> GetLines(IGeometry geom, ICollection <IGeometry> lines) { if (geom is ILineString) { lines.Add(geom); } else if (geom is IGeometryCollection) { geom.Apply(new LineStringExtracter(lines)); } // skip non-LineString elemental geometries return(lines); }
//static bool IsOfClass<T>(Object o /*, Type clz*/) where T:class, IGeometry //{ // return o is T; //} ///<summary> /// Extracts the <c>T</c> components from an <see cref="IGeometry"/> and adds them to the provided <see cref="List{T}"/>. ///</summary> /// <param name="geom">the geometry from which to extract</param> /// <param name="list">the list to add the extracted elements to</param> /// <typeparam name="T">The geometry type to extract</typeparam> public static IList <IGeometry> Extract <T>(IGeometry geom, IList <IGeometry> list) where T : class, IGeometry { if (geom is T) { list.Add(geom as T); } else if (geom is IGeometryCollection) { geom.Apply(new GeometryExtracter <T>(list)); } // skip non-T elemental geometries return(list); }
///<summary> /// Extracts the <see cref="ILineString"/> elements from a single <see cref="IGeometry"/> /// and adds them to the<see cref="List{ILineString}"/>. ///</summary> /// <param name="geom">The geometry from which to extract</param> /// <param name="lines">The list to add the extracted elements to</param> /// <returns>The <paramref name="lines"/> list argument</returns> public static ICollection<IGeometry> GetLines(IGeometry geom, ICollection<IGeometry> lines) { if (geom is ILineString) { lines.Add(geom); } else if (geom is IGeometryCollection) { geom.Apply(new LineStringExtracter(lines)); } // skip non-LineString elemental geometries return lines; }
/// <summary> /// Extracts the <see cref="IPolygon"/> elements from a single <see cref="IGeometry"/> and adds them to the provided <see cref="IList{IPolygon}"/>. /// </summary> /// <param name="geom">The geometry from which to extract</param> /// <param name="list">The list to add the extracted elements to</param> /// <returns></returns> public static IList <IGeometry> GetPolygons(IGeometry geom, IList <IGeometry> list) { if (geom is IPolygon) { list.Add(geom); } else if (geom is IGeometryCollection) { geom.Apply(new PolygonExtracter(list)); } // skip non-Polygonal elemental geometries return(list); }
/// <summary> /// Extracts the <see cref="IPolygon"/> elements from a single <see cref="IGeometry"/> and adds them to the provided <see cref="IList{IPolygon}"/>. /// </summary> /// <param name="geom">The geometry from which to extract</param> /// <param name="list">The list to add the extracted elements to</param> /// <returns></returns> public static IList<IGeometry> GetPolygons(IGeometry geom, IList<IGeometry> list) { if (geom is IPolygon) { list.Add(geom); } else if (geom is IGeometryCollection) { geom.Apply(new PolygonExtracter(list)); } // skip non-Polygonal elemental geometries return list; }
/// <summary> /// Creates facet sequences from a given geometry /// </summary> /// <param name="g">The geometry</param> /// <returns>A list of <see cref="FacetSequence"/>s</returns> private static List<FacetSequence> ComputeFacetSequences(IGeometry g) { var sections = new List<FacetSequence>(); g.Apply(new GeometryComponentFilter( delegate(IGeometry geom) { ICoordinateSequence seq; if (geom is ILineString) { seq = ((ILineString) geom).CoordinateSequence; AddFacetSequences(seq, sections); } else if (geom is IPoint) { seq = ((IPoint) geom).CoordinateSequence; AddFacetSequences(seq, sections); } })); return sections; }
private void CheckCoordinates(IGeometry geom) { geom.Apply(new ShapeReaderWriterCoordinateSequenceFilter((NtsSpatialContext)Ctx, normalizeGeomCoords)); }
private void ComputeMaxVertexDistance(IGeometry curve) { MaxPointDistanceFilter distFilter = new MaxPointDistanceFilter(_inputGeom); curve.Apply(distFilter); _maxPtDist.SetMaximum(distFilter.MaxPointDistance); }
/** * If <code>geom</code> spans the dateline, then this modifies it to be a * valid JTS geometry that extends to the right of the standard -180 to +180 * width such that some points are greater than +180 but some remain less. * Takes care to invoke {@link com.vividsolutions.jts.geom.Geometry#geometryChanged()} * if needed. * * @return The number of times the geometry spans the dateline. >= 0 */ private static int UnwrapDateline(IGeometry geom) { if (geom.EnvelopeInternal.Width < 180) return 0;//can't possibly cross the dateline int[] result = { 0 };//an array so that an inner class can modify it. geom.Apply(new S4nGeometryFilter(result)); int crossings = result[0]; return crossings; }
public static IGeometry GetPolygonHoles(IGeometry geom) { IList<IGeometry> holePolys = new List<IGeometry>(); geom.Apply(new InternalGeometryFilterImpl(holePolys)); return geom.Factory.BuildGeometry(holePolys); }
private static void ShiftGeomByX(IGeometry geom, int xShift) { if (xShift == 0) return; geom.Apply(new S4nCoordinateSequenceFilter(xShift)); }
/// <summary> /// Adds a Geometry to be processed. May be called multiple times. /// Any dimension of Geometry may be added; the constituent linework will be /// extracted. /// </summary> /// <param name="geometry"></param> public void Add(IGeometry geometry) { geometry.Apply(new AnonymousGeometryComponentFilterImpl(this)); }
/// <summary> /// Extracts the linear components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>LineExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom">The point from which to extract linear components.</param> /// <returns>The list of linear components.</returns> public static ICollection<IGeometry> GetLines(IGeometry geom) { var lines = new Collection<IGeometry>(); geom.Apply(new LinearComponentExtracter(lines)); return lines; }
/// <summary> /// Add a point to the set of geometries whose common bits are /// being computed. After this method has executed the /// common coordinate reflects the common bits of all added /// geometries. /// </summary> /// <param name="geom">A Geometry to test for common bits.</param> public virtual void Add(IGeometry geom) { geom.Apply(_ccFilter); _commonCoord = _ccFilter.CommonCoordinate; }
/// <summary> /// Add a point to the set of geometries whose common bits are /// being computed. After this method has executed the /// common coordinate reflects the common bits of all added /// geometries. /// </summary> /// <param name="geom">A Geometry to test for common bits.</param> public void Add(IGeometry geom) { geom.Apply(ccFilter); commonCoord = ccFilter.CommonCoordinate; }
/// <summary> /// Returns the Polygon components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>PolygonExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom"></param> public static IList GetPolygons(IGeometry geom) { IList comps = new ArrayList(); geom.Apply(new PolygonExtracter(comps)); return comps; }
/// <summary> /// Returns the Point components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>PointExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom"></param> public static IList GetPoints(IGeometry geom) { IList pts = new ArrayList(); geom.Apply(new PointExtracter(pts)); return pts; }
public void ExpandToInclude(IGeometry g) { g.Apply(new BoundingOctagonComponentFilter(this)); }
static IList<ISegmentString> ExtractTaggedSegmentStrings(IGeometry geom, IPrecisionModel pm) { var segStrings = new List<ISegmentString>(); var filter = new GeometryComponentFilter( delegate (IGeometry fgeom) { // Extract linework for lineal components only if (!(fgeom is ILineString)) return; // skip empty lines if (geom.NumPoints <= 0) return; var roundPts = Round(((ILineString)geom).CoordinateSequence, pm); segStrings.Add(new NodedSegmentString(roundPts, geom)); }); geom.Apply(filter); return segStrings; }
protected IGeometry Rotate(IGeometry geom) { if (_rotationAngle != 0.0) { var centre = _dim.Centre; var trans = AffineTransformation.RotationInstance(_rotationAngle, centre.X, centre.Y); geom.Apply(trans); } return geom; }
/// <summary> /// Returns a list containing a point from each Polygon, LineString, and Point /// found inside the specified point. Thus, if the specified point is /// not a GeometryCollection, an empty list will be returned. The elements of the list /// are <c>com.vividsolutions.jts.operation.distance.GeometryLocation</c>s. /// </summary> public static IList<GeometryLocation> GetLocations(IGeometry geom) { var locations = new List<GeometryLocation>(); geom.Apply(new ConnectedElementLocationFilter(locations)); return locations; }
/// <summary> /// Extracts the linear components from a single <see cref="IGeometry"/> /// and adds them to the provided <see cref="ICollection{ILineString}"/>. /// </summary> /// <param name="geom">The geometry from which to extract linear components</param> /// <param name="lines">The Collection to add the extracted linear components to</param> /// <param name="forceToLineString"></param> /// <returns>The Collection of linear components (LineStrings or LinearRings)</returns> public static ICollection<IGeometry> GetLines(IGeometry geom, ICollection<IGeometry> lines, bool forceToLineString) { geom.Apply(new LinearComponentExtracter(lines, forceToLineString)); return lines; }
/// <summary> /// Add a point to the linework to be polygonized. /// May be called multiple times. /// Any dimension of Geometry may be added; /// the constituent linework will be extracted and used /// </summary> /// <param name="g">A <c>Geometry</c> with linework to be polygonized.</param> public virtual void Add(IGeometry g) { g.Apply(_lineStringAdder); }
/// <summary> /// Extracts the linear components from a single point. /// If more than one point is to be processed, it is more /// efficient to create a single <c>LineExtracterFilter</c> instance /// and pass it to multiple geometries. /// </summary> /// <param name="geom">The point from which to extract linear components.</param> /// <returns>The list of linear components.</returns> public static IList GetLines(IGeometry geom) { IList lines = new ArrayList(); geom.Apply(new LinearComponentExtracter(lines)); return lines; }
/// <summary> /// Returns a list containing a point from each Polygon, LineString, and Point /// found inside the specified point. Thus, if the specified point is /// not a GeometryCollection, an empty list will be returned. The elements of the list /// are <c>com.vividsolutions.jts.operation.distance.GeometryLocation</c>s. /// </summary> public static IList GetLocations(IGeometry geom) { IList locations = new ArrayList(); geom.Apply(new ConnectedElementLocationFilter(locations)); return locations; }
/// <summary> /// Add a point to the linework to be polygonized. /// May be called multiple times. /// Any dimension of Geometry may be added; /// the constituent linework will be extracted and used /// </summary> /// <param name="g">A <c>Geometry</c> with linework to be polygonized.</param> public void Add(IGeometry g) { g.Apply(lineStringAdder); }
private static void SetZ(IGeometry g) { g.Apply(new AverageZFilter()); }