示例#1
0
        static void SpatialTrace_GeometryWithDEMGrid(ElevationService elevationService, IGeoTiffService geoTiffService, string wktBbox, DEMDataSet dataSet)
        {
            SpatialTrace.Enable();
            DEM.Net.Lib.BoundingBox bbox = null;
            if (wktBbox != null)
            {
                SqlGeometry geom = GeometryService.ParseWKTAsGeometry(wktBbox);
                SpatialTrace.TraceGeometry(geom, "Bbox");
                bbox = geom.ToGeography().STBuffer(60).GetBoundingBox();

                //SpatialTrace.Indent("Line Segments");
                //int i = 0;
                //foreach (var seg in geom.Segments())
                //{
                //	i++;
                //	Color color = (i % 2 == 0) ? Colors.Blue : Colors.Red;
                //	SpatialTrace.SetLineColor(color);
                //	SpatialTrace.TraceGeometry(seg, "Seg" + i, "Seg" + i);
                //}

                SpatialTrace.Unindent();
            }



            Dictionary <string, DemFileReport> tiles = geoTiffService.GenerateReport(dataSet, bbox);

            SpatialTrace.Indent("DEM tiles");
            SpatialTrace.SetLineColor(Colors.Black);
            foreach (var tile in tiles)
            {
                SpatialTrace.SetFillColor(tile.Value.IsExistingLocally ? Color.FromArgb(128, 0, 255, 0) : Color.FromArgb(128, 255, 0, 0));

                SqlGeometry tileBbox = tile.Value.Source.BBox.AsGeomety();
                SpatialTrace.TraceGeometry(tileBbox, $"{tile.ToString()}");
            }
            SpatialTrace.Unindent();

            // View spatial trace in bin\debug with spatial trace viewer
            SpatialTrace.ShowDialog();
            SpatialTrace.Disable();
        }
示例#2
0
        public void LineLineIntersectionTest()
        {
            string   wkt1  = "LINESTRING(-5.888671875 47.90161354142077,3.4716796875 44.11914151643737)";
            string   wkt2  = "LINESTRING(-2.8564453125 44.30812668488613,5.625 48.166085419012525)";
            Geometry geom1 = GeometryService.ParseWKTAsGeometry(wkt1);
            Geometry geom2 = GeometryService.ParseWKTAsGeometry(wkt2);


            Geometry intersection = geom1.Intersection(geom2);

            GeoSegment seg1 = geom1.Segments().First();
            GeoSegment seg2 = geom2.Segments().First();
            GeoPoint   intersectionResult = GeoPoint.Zero;

            bool intersects = GeometryService.LineLineIntersection(out intersectionResult, seg1, seg2);


            double dist = intersection.Coordinate.ToGeoPoint().DistanceTo(intersectionResult);


            Assert.True(dist < 0.05d, "Problem in intersection calculation.");
        }
示例#3
0
        public void LineLineIntersectionTest()
        {
            string      wkt1         = "LINESTRING(-5.888671875 47.90161354142077,3.4716796875 44.11914151643737)";
            string      wkt2         = "LINESTRING(-2.8564453125 44.30812668488613,5.625 48.166085419012525)";
            SqlGeometry geom1        = GeometryService.ParseWKTAsGeometry(wkt1);
            SqlGeometry geom2        = GeometryService.ParseWKTAsGeometry(wkt2);
            SqlGeometry intersection = geom1.STIntersection(geom2);

            GeoSegment seg1 = new GeoSegment(new GeoPoint(geom1.STStartPoint().STY.Value, geom1.STStartPoint().STX.Value), new GeoPoint(geom1.STEndPoint().STY.Value, geom1.STEndPoint().STX.Value));
            GeoSegment seg2 = new GeoSegment(new GeoPoint(geom2.STStartPoint().STY.Value, geom2.STStartPoint().STX.Value), new GeoPoint(geom2.STEndPoint().STY.Value, geom2.STEndPoint().STX.Value));
            GeoPoint   intersectionResult = GeoPoint.Zero;

            bool intersects = GeometryService.LineLineIntersection(out intersectionResult, seg1, seg2);


            SqlGeography geog1 = null;

            intersection.TryToGeography(out geog1);
            SqlGeography geog2 = SqlGeography.Point(intersectionResult.Latitude, intersectionResult.Longitude, 4326);
            double       dist  = geog1.STDistance(geog2).Value;

            Assert.IsTrue(dist < 0.05d, "Problem in intersection calculation.");
        }
示例#4
0
        static DEM.Net.Lib.BoundingBox GetBoundingBox(string wkt, double buffer = 60)
        {
            SqlGeometry geom = GeometryService.ParseWKTAsGeometry(wkt);

            return(geom.ToGeography().STBuffer(60).GetBoundingBox());
        }