public RelateComputer(GeometryGraph[] arg) { li = new RobustLineIntersector(); ptLocator = new PointLocator(); nodes = new NodeMap(new RelateNodeFactory()); isolatedEdges = new EdgeCollection(); this.arg = arg; }
public void testPointLocator() { var pointLocator = new PointLocator(); var polygon = reader.Read("POLYGON ((70 340, 430 50, 70 50, 70 340))"); Assert.AreEqual(Location.Exterior, pointLocator.Locate(new Coordinate(420, 340), polygon)); Assert.AreEqual(Location.Boundary, pointLocator.Locate(new Coordinate(350, 50), polygon)); Assert.AreEqual(Location.Boundary, pointLocator.Locate(new Coordinate(410, 50), polygon)); Assert.AreEqual(Location.Interior, pointLocator.Locate(new Coordinate(190, 150), polygon)); }
public LineBuilder(OverlayOp op, GeometryFactory geometryFactory, PointLocator ptLocator) { lineEdgesList = new ArrayList(); resultLineList = new GeometryList(); this.op = op; this.geometryFactory = geometryFactory; this.ptLocator = ptLocator; }
public void TestPolygon() { var pointLocator = new PointLocator(); var polygon = reader.Read("POLYGON ((70 340, 430 50, 70 50, 70 340))"); Assert.That(pointLocator.Locate(new Coordinate(420, 340), polygon), Is.EqualTo(Location.Exterior)); Assert.That(pointLocator.Locate(new Coordinate(350, 50), polygon), Is.EqualTo(Location.Boundary)); Assert.That(pointLocator.Locate(new Coordinate(410, 50), polygon), Is.EqualTo(Location.Boundary)); Assert.That(pointLocator.Locate(new Coordinate(190, 150), polygon), Is.EqualTo(Location.Interior)); }
public void run(int lookups) { double s = 0; s += Traverse(); pointlocator = new PointLocator <int>(ugly); pointlocator.Build(); LookUp(lookups, 567); }
public string GetDistrics(Coordinate coordinate) { foreach (var item in Streets) { var pointLocator = new PointLocator(); if (pointLocator.Intersects(coordinate, item.BasicGeometry as IGeometry)) { return(item.DataRow["NAME"].ToString()); } } return(null); }
/// <summary> /// Tests whether any representative of the target geometry intersects the test geometry. /// This is useful in A/A, A/L, A/P, L/P, and P/P cases. /// </summary> /// <param name="testGeom">The test geometry</param> /// <returns>true if any component intersects the areal test geometry</returns> public bool IsAnyTargetComponentInTest(Geometry testGeom) { var locator = new PointLocator(); foreach (var representativePoint in RepresentativePoints) { if (locator.Intersects(representativePoint, testGeom)) { return(true); } } return(false); }
/// <summary> /// Tests whether any representative point of the test Geometry intersects /// the target geometry. /// </summary> /// <remarks> /// Only handles test geometries which are Puntal (dimension 0) /// </remarks> /// <param name="testGeom">A Puntal geometry to test</param> /// <returns>true if any point of the argument intersects the prepared geometry</returns> protected bool IsAnyTestPointInTarget(IGeometry testGeom) { /* * This could be optimized by using the segment index on the lineal target. * However, it seems like the L/P case would be pretty rare in practice. */ var locator = new PointLocator(); var coords = ComponentCoordinateExtracter.GetCoordinates(testGeom); foreach (var p in coords) { if (locator.Intersects(p, prepLine.Geometry)) { return(true); } } return(false); }
/// <summary> /// Initializes a new instance of <see cref="DistanceOp"/> class /// that computes the distance and closest points between the /// two specified geometries. /// </summary> public DistanceOp(Geometry g0, Geometry g1) { if (g0 == null) { throw new ArgumentNullException("g0"); } if (g1 == null) { throw new ArgumentNullException("g1"); } ptLocator = new PointLocator(); minDistance = Double.MaxValue; this.geom = new Geometry[2]; geom[0] = g0; geom[1] = g1; m_objFactory = g0.Factory; if (m_objFactory == null) { m_objFactory = g1.Factory; } }
public OverlayOp(Geometry g0, Geometry g1) : base(g0, g1) { if (g0 == null) { throw new ArgumentNullException("g0"); } if (g1 == null) { throw new ArgumentNullException("g1"); } ptLocator = new PointLocator(); edgeList = new EdgeList(); resultPolyList = new GeometryList(); resultLineList = new GeometryList(); resultPointList = new GeometryList(); graph = new PlanarGraph(new OverlayNodeFactory()); // Use factory of primary geometry. // Note that this does NOT handle mixed-precision arguments // where the second arg has greater precision than the first. geomFact = g0.Factory; }
public Geometry Union() { var locater = new PointLocator(); // use a set to eliminate duplicates, as required for union var exteriorCoords = new HashSet <Coordinate>(); foreach (Point point in PointExtracter.GetPoints(_pointGeom)) { var coord = point.Coordinate; var loc = locater.Locate(coord, _otherGeom); if (loc == Location.Exterior) { exteriorCoords.Add(coord); } } // if no points are in exterior, return the other geom if (exteriorCoords.Count == 0) { return(_otherGeom); } // make a puntal geometry of appropriate size var exteriorCoordsArray = new Coordinate[exteriorCoords.Count]; exteriorCoords.CopyTo(exteriorCoordsArray, 0); Array.Sort(exteriorCoordsArray); var coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoordsArray); var ptComp = coords.Count == 1 ? (Geometry)_geomFact.CreatePoint(coords) : _geomFact.CreateMultiPoint(coords); // add point component to the other geometry return(GeometryCombiner.Combine(ptComp, _otherGeom)); }
public IGeometry Union() { PointLocator locater = new PointLocator(); // use a set to eliminate duplicates, as required for union #if Goletas HashSet <ICoordinate> exteriorCoords = new HashSet <ICoordinate>(); #else TreeSet exteriorCoords = new TreeSet(); #endif foreach (IPoint point in PointExtracter.GetPoints(_pointGeom)) { ICoordinate coord = point.Coordinate; Locations loc = locater.Locate(coord, _otherGeom); if (loc == Locations.Exterior) { exteriorCoords.Add(coord); } } // if no points are in exterior, return the other geom if (exteriorCoords.Count == 0) { return(_otherGeom); } // make a puntal geometry of appropriate size IGeometry ptComp = null; ICoordinateSequence coords = _geomFact.CoordinateSequenceFactory.Create(exteriorCoords.ToArray()); ptComp = coords.Count == 1 ? (IGeometry)_geomFact.CreatePoint(coords.GetCoordinate(0)) : _geomFact.CreateMultiPoint(coords); // add point component to the other geometry return(GeometryCombiner.Combine(ptComp, _otherGeom)); }
/// <summary> /// /// </summary> /// <param name="op"></param> /// <param name="geometryFactory"></param> /// <param name="ptLocator"></param> public LineBuilder(OverlayOp op, IGeometryFactory geometryFactory, PointLocator ptLocator) { this.op = op; this.geometryFactory = geometryFactory; this.ptLocator = ptLocator; }
/// <summary> /// /// </summary> /// <param name="op"></param> /// <param name="geometryFactory"></param> /// <param name="ptLocator"></param> public LineBuilder(OverlayOp op, GeometryFactory geometryFactory, PointLocator ptLocator) { _op = op; _geometryFactory = geometryFactory; _ptLocator = ptLocator; }
public ImageProcessingResults3D Process(List <HImage> images, List <PointSettingViewModel> pointSettings, ISnackbarMessageQueue messageQueue) { var bottomImage = images[0]; var leftImage = images[1]; var rightImage = images[2]; HTuple imageWidth, imageHeight; rightImage.GetImageSize(out imageWidth, out imageHeight); HObject leftImageAligned, bottomImageAligned, rightImageAligned, contours, imageComposed, regionB; HTuple rowB, colB, rowC, colC; _halconScripts.get_location(leftImage, rightImage, bottomImage, out leftImageAligned, out rightImageAligned, out bottomImageAligned, out contours, out imageComposed, out regionB, _shapeModelHandleRight, out rowB, out colB, out rowC, out colC); // Translate base var lineB = new Line(colB.DArr[0], rowB.DArr[0], colB.DArr[1], rowB.DArr[1], true).SortLeftRight(); var lineC = new Line(colC.DArr[0], rowC.DArr[0], colC.DArr[1], rowC.DArr[1], true).SortUpDown().InvertDirection(); var xAxis = lineB.Translate(1.0 / _yCoeff * -6.788); xAxis.IsVisible = true; var yAxis = lineC.Translate(1.0 / _xCoeff * -19.605); yAxis.IsVisible = true; // Record debugging data var recordings = new List <ICsvColumnElement>(); recordings.Add(new AngleItem() { Name = "BC", Value = lineB.AngleWithLine(lineC) }); recordings.Add(new AngleItem() { Name = "C", Value = lineC.AngleWithLine(new Line(1, 0, 2, 0)) }); var imageB = bottomImageAligned.HobjectToHimage().ConvertImageType("real").ScaleImage(0.001, 0); var imageL = leftImageAligned.HobjectToHimage().ConvertImageType("real").ScaleImage(0.001, 0); var imageR = rightImageAligned.HobjectToHimage().ConvertImageType("real").ScaleImage(0.001, 0); imageB.GetImageSize(out imageWidth, out imageHeight); imageL.GetImageSize(out imageWidth, out imageHeight); imageR.GetImageSize(out imageWidth, out imageHeight); var visualBR = VisualizeAlignment(imageR, imageB); var visualLR = VisualizeAlignment(imageR, imageL); var pointLocator = new PointLocator(xAxis, yAxis, _xCoeff, -_yCoeff); var pointMarkers = pointLocator.LocatePoints(pointSettings, new List <HImage>() { imageB, imageL, imageR }); var output = new ImageProcessingResults3D() { Images = new List <HImage>() { imageB, imageL, imageR, visualBR, visualLR }, PointMarkers = pointMarkers, RecordingElements = recordings, ChangeOfBaseInv = MathUtils.GetChangeOfBaseInv(xAxis, yAxis, 1 / _xCoeff, 1 / _yCoeff), Edges = regionB }; output.AddLineRegion(contours); return(output); }
public PointBuilder(OverlayOp op, IGeometryFactory geometryFactory, PointLocator ptLocator = null) : this(op, geometryFactory) { }
//private PointLocator _ptLocator; /// <summary> /// /// </summary> /// <param name="op"></param> /// <param name="geometryFactory"></param> /// <param name="ptLocator"></param> public PointBuilder(OverlayOp op, IGeometryFactory geometryFactory, PointLocator ptLocator) { _op = op; _geometryFactory = geometryFactory; //_ptLocator = ptLocator; }