private static IGeometry CreateJ(IGeometry g) { var gf = FunctionsUtil.GetFactoryOrDefault(g); var jTop = new Coordinate[] { new Coordinate(0, HEIGHT), new Coordinate(J_WIDTH, HEIGHT), new Coordinate(J_WIDTH, J_RADIUS) }; var jBottom = new Coordinate[] { new Coordinate(J_WIDTH - J_RADIUS, 0), new Coordinate(0, 0) }; var gsf = new GeometricShapeFactory(gf); gsf.Base = new Coordinate(J_WIDTH - 2 * J_RADIUS, 0); gsf.Size = 2 * J_RADIUS; gsf.NumPoints = 10; var jArc = gsf.CreateArc(1.5 * Math.PI, 0.5 * Math.PI); var coordList = new CoordinateList(); coordList.Add(jTop, false); coordList.Add(((IGeometry)jArc).Reverse().Coordinates, false, 1, jArc.NumPoints - 1); coordList.Add(jBottom, false); return(gf.CreateLineString(coordList.ToCoordinateArray())); }
private IGeometry RandomGeometry(int points) { //a circle NtsSpatialContext ctx = (NtsSpatialContext)base.ctx; GeometricShapeFactory gsf = new GeometricShapeFactory(ctx.GeometryFactory); gsf.Centre = (new Coordinate(0, 0)); gsf.Size = (180);//diameter gsf.NumPoints = (points); return(gsf.CreateCircle()); }
public void TestBigPolygon() { var shapeFactory = new GeometricShapeFactory(GeomFactory); shapeFactory.Base = new Coordinate(0, 0); shapeFactory.Size = 1000; shapeFactory.NumPoints = 1000; IGeometry geom = shapeFactory.CreateRectangle(); RunWKBTest(geom, 2, false); }
public static Polygon CreateCircle(Coordinate origin, double size, int nPts) { var gsf = new GeometricShapeFactory(); gsf.Centre = origin; gsf.Size = size; gsf.NumPoints = nPts; var circle = gsf.CreateCircle(); return(circle); }
static IGeometry CreateTestCircle(Coordinate origin, double size, int nPts) { GeometricShapeFactory gsf = new GeometricShapeFactory(); gsf.Centre = origin; gsf.Size = size; gsf.NumPoints = nPts; IGeometry circle = gsf.CreateCircle(); // System.out.println(circle); return(circle); }
static ILineString CreateTestLine(Coordinate basePt, double size, int nPts) { var gsf = new GeometricShapeFactory(); gsf.Centre = basePt; gsf.Size = size; gsf.NumPoints = nPts; IGeometry circle = gsf.CreateCircle(); // System.out.println(circle); return((ILineString)circle.Boundary); }
public IGeometry CreateLine(Coordinate @base, double size, int nPts) { var gsf = new GeometricShapeFactory(); gsf.Centre = _origin; gsf.Size = size; gsf.NumPoints = nPts; var circle = gsf.CreateCircle(); // System.out.println(circle); return(circle.Boundary); }
public static Polygon CreateSquare(Coordinate origin, double size) { var gsf = new GeometricShapeFactory(); gsf.Centre = origin; gsf.Size = size; gsf.NumPoints = 4; var g = gsf.CreateRectangle(); // Polygon gRect = gsf.createRectangle(); // Geometry g = gRect.getExteriorRing(); return(g); }
static IGeometry CreateCircle(Coordinate origin, double size, int nPts) { GeometricShapeFactory gsf = new GeometricShapeFactory(); gsf.Centre = origin; gsf.Size = size; gsf.NumPoints = nPts; IGeometry circle = gsf.CreateCircle(); // Polygon gRect = gsf.createRectangle(); // Geometry g = gRect.getExteriorRing(); return(circle); }
public IGeometry CreateCircle(int nPts) { var gsf = new GeometricShapeFactory(_geomFact); gsf.Centre = _origin; gsf.Size = _size; gsf.NumPoints = nPts; var circle = gsf.CreateCircle(); // var gRect = gsf.CreateRectangle(); // var g = gRect.ExteriorRing); return(circle); }
public static IGeometry Supercircle(IGeometry g, int nPts, double pow) { var gsf = new GeometricShapeFactory(); gsf.NumPoints = nPts; if (g != null) { gsf.Envelope = g.EnvelopeInternal; } else { gsf.Envelope = new Envelope(0, 1, 0, 1); } return(gsf.CreateSupercircle(pow)); }
public void GetIntersectionAreaCircles() { var factory = new GeometricShapeFactory { Size = 20 }; var circle = factory.CreateCircle(); factory.Centre = new Coordinate(0, 5); var circle2 = factory.CreateCircle(); //self area Assert.AreEqual(circle.Area, GeometryHelper.GetSampledIntersectionArea(circle, circle), 10); var actualArea = GeometryHelper.GetIntersectionArea(circle, circle2); Assert.AreEqual(102.68839131234732, actualArea, 0.1); Assert.AreEqual(actualArea, GeometryHelper.GetSampledIntersectionArea(circle, circle2), 10); }
private static IGeometry CreateS(IGeometry g) { var gf = FunctionsUtil.GetFactoryOrDefault(g); double centreX = WIDTH - S_RADIUS; var top = new[] { new Coordinate(WIDTH, HEIGHT), new Coordinate(centreX, HEIGHT) }; var bottom = new[] { new Coordinate(centreX, 0), new Coordinate(WIDTH - 2 * S_RADIUS, 0) }; var gsf = new GeometricShapeFactory(gf); gsf.Centre = new Coordinate(centreX, HEIGHT - S_RADIUS); gsf.Size = 2 * S_RADIUS; gsf.NumPoints = 10; var arcTop = gsf.CreateArc(0.5 * Math.PI, Math.PI); var gsf2 = new GeometricShapeFactory(gf); gsf2.Centre = new Coordinate(centreX, S_RADIUS); gsf2.Size = 2 * S_RADIUS; gsf2.NumPoints = 10; var arcBottom = (ILineString)((IGeometry)gsf2.CreateArc(1.5 * Math.PI, Math.PI)).Reverse(); var coordList = new CoordinateList(); coordList.Add(top, false); coordList.Add(arcTop.Coordinates, false, 1, arcTop.NumPoints - 1); coordList.Add(new Coordinate(centreX, HEIGHT / 2)); coordList.Add(arcBottom.Coordinates, false, 1, arcBottom.NumPoints - 1); coordList.Add(bottom, false); return(gf.CreateLineString(coordList.ToCoordinateArray())); }
private IGeometry getGeometryFromPoint(Coordinate coord, double size) { coord.X -= size / 2; coord.Y -= size / 2; GeometricShapeFactory gf = new GeometricShapeFactory(); gf.Base = coord; gf.Centre = coord; gf.Size = size; gf.Width = size; gf.Height = size; IPolygon circle = gf.CreateCircle(); circle.Coordinates[circle.Coordinates.Length - 1] = circle.Coordinates.First(); LinearRing lr = new LinearRing(circle.Coordinates); return(new Polygon(lr)); }
public void MovePolygonWithTrackersShouldBeFast() { var factory = new GeometricShapeFactory(); factory.NumPoints = 10000; // many factory.Size = 300; var circle = factory.CreateCircle(); var circleSource = (IGeometry)circle.Clone(); var trackers = new List <IGeometry>(); for (int i = 0; i < circle.Coordinates.Length; i++) { trackers.Add(new Point((ICoordinate)circle.Coordinates[i].Clone())); } var handles = Enumerable.Range(0, trackers.Count).ToList(); TestHelper.AssertIsFasterThan(40, () => noFallOffPolicy.Move(circle, circleSource, trackers, handles, 0, 5, 5)); }
public void GetTimeSeriesFromTimeDependentPolygonFeatureCoverageWithCentroid() { //QueryTimeSeriesMapCommand uses centroid var coverage = GetTimeDependentFeatureCoverage(); foreach (var feature in coverage.Features) { var factory = new GeometricShapeFactory(); factory.Centre = feature.Geometry.Coordinate; factory.Size = 5; feature.Geometry = factory.CreateCircle(); } var coverageName = "Waste disposal"; coverage.Name = coverageName; var t1 = new DateTime(2000, 1, 1); var t2 = new DateTime(2000, 1, 2); var t3 = new DateTime(2000, 1, 3); //set some values for each time step coverage[t1] = new[] { 1.0, 2.0, 3.0 }; coverage[t2] = new[] { 4.0, 5.0, 6.0 }; coverage[t3] = new[] { 7.0, 8.0, 9.0 }; //get a timeseries for the 1st feature var firstFeature = coverage.FeatureVariable.Values.OfType <SimpleFeature>().First(); var featureName = "Amsterdam"; firstFeature.Name = featureName; var timesSeries = coverage.GetTimeSeries(firstFeature.Geometry.Centroid.Coordinate); Assert.AreEqual(new[] { t1, t2, t3 }, timesSeries.Arguments[0].Values); Assert.AreEqual(new[] { 1.0d, 4.0d, 7.0d }, timesSeries.Components[0].Values); Assert.AreEqual(coverageName + " at " + featureName, timesSeries.Name); //check it is reduced Assert.AreEqual(1, timesSeries.Arguments.Count); }
public FormaGeometrica(EGeometricShapes eGeometricShapes, decimal side1, decimal?side2, decimal?base1, decimal?base2, decimal?height) { _iGeometricShape = GeometricShapeFactory.GetGeometricShape(eGeometricShapes, side1, side2, base1, base2, height); }
/// <summary> /// Gets a NTS <see cref="IGeometry"/> for the given <see cref="IShape"/>. Some shapes hold a /// NTS geometry whereas new ones must be created for the rest. /// </summary> /// <param name="shape">Not null</param> /// <returns>Not null</returns> public virtual IGeometry GetGeometryFrom(IShape shape) { if (shape is NtsGeometry) { return(((NtsGeometry)shape).Geometry); } if (shape is NtsPoint) { return(((NtsPoint)shape).Geometry); } var point = shape as Shapes.IPoint; if (point != null) { return(m_geometryFactory.CreatePoint(new Coordinate(point.X, point.Y))); } var r = shape as IRectangle; if (r != null) { if (r.CrossesDateLine) { var pair = new List <IGeometry>(2) { m_geometryFactory.ToGeometry(new Envelope( r.MinX, WorldBounds.MaxX, r.MinY, r.MaxY)), m_geometryFactory.ToGeometry(new Envelope( WorldBounds.MinX, r.MaxX, r.MinY, r.MaxY)) }; return(m_geometryFactory.BuildGeometry(pair));//a MultiPolygon or MultiLineString } else { return(m_geometryFactory.ToGeometry(new Envelope(r.MinX, r.MaxX, r.MinY, r.MaxY))); } } var circle = shape as ICircle; if (circle != null) { // TODO, this should maybe pick a bunch of points // and make a circle like: // http://docs.codehaus.org/display/GEOTDOC/01+How+to+Create+a+Geometry#01HowtoCreateaGeometry-CreatingaCircle // If this crosses the dateline, it could make two parts // is there an existing utility that does this? if (circle.BoundingBox.CrossesDateLine) { throw new ArgumentException("Doesn't support dateline cross yet: " + circle);//TODO } var gsf = new GeometricShapeFactory(m_geometryFactory) { Size = circle.BoundingBox.Width / 2.0f, NumPoints = 4 * 25,//multiple of 4 is best Centre = new Coordinate(circle.Center.X, circle.Center.Y) }; return(gsf.CreateCircle()); } throw new InvalidShapeException("can't make Geometry from: " + shape); }