Ejemplo n.º 1
0
        public List <GeoPoint> GetLineGeometryElevation(IEnumerable <GeoPoint> lineGeoPoints, DEMDataSet dataSet, InterpolationMode interpolationMode = InterpolationMode.Bilinear)
        {
            if (lineGeoPoints == null)
            {
                throw new ArgumentNullException("lineGeoPoints", "Point list is null");
            }

            SqlGeometry geometry = GeometryService.ParseGeoPointAsGeometryLine(lineGeoPoints);

            return(GetLineGeometryElevation(geometry, dataSet, interpolationMode));
        }
Ejemplo n.º 2
0
 public string GetDEMLocalPath(DEMDataSet dataSet)
 {
     return(_IGeoTiffService.GetLocalDEMPath(dataSet));
 }
Ejemplo n.º 3
0
        public List <GeoPoint> GetLineGeometryElevation(SqlGeometry lineStringGeometry, DEMDataSet dataSet, InterpolationMode interpolationMode = InterpolationMode.Bilinear)
        {
            if (lineStringGeometry == null || lineStringGeometry.IsNull)
            {
                return(null);
            }
            if (lineStringGeometry.STGeometryType().Value != "LineString")
            {
                throw new Exception("Geometry must be a linestring");
            }
            if (lineStringGeometry.STSrid.Value != 4326)
            {
                throw new Exception("Geometry SRID must be set to 4326 (WGS 84)");
            }

            BoundingBox         bbox  = lineStringGeometry.GetBoundingBox();
            List <FileMetadata> tiles = this.GetCoveringFiles(bbox, dataSet);

            // Init interpolator
            IInterpolator interpolator = GetInterpolator(interpolationMode);

            int      numPointsSql  = lineStringGeometry.STNumPoints().Value;
            var      sqlStart      = lineStringGeometry.STPointN(1);
            var      sqlEnd        = lineStringGeometry.STPointN(numPointsSql);
            GeoPoint start         = new GeoPoint(sqlStart.STY.Value, sqlStart.STX.Value);
            GeoPoint end           = new GeoPoint(sqlEnd.STY.Value, sqlEnd.STX.Value);
            double   lengthMeters  = start.DistanceTo(end);
            int      demResolution = dataSet.ResolutionMeters;
            int      totalCapacity = 2 * (int)(lengthMeters / demResolution);

            List <GeoPoint> geoPoints = new List <GeoPoint>(totalCapacity);

            using (GeoTiffDictionary adjacentGeoTiffs = new GeoTiffDictionary())
            {
                bool isFirstSegment = true; // used to return first point only for first segments, for all other segments last point will be returned
                foreach (SqlGeometry segment in lineStringGeometry.Segments())
                {
                    List <FileMetadata> segTiles = this.GetCoveringFiles(segment.GetBoundingBox(), dataSet, tiles);

                    // Find all intersection with segment and DEM grid
                    List <GeoPoint> intersections = this.FindSegmentIntersections(segment.STStartPoint().STX.Value
                                                                                  , segment.STStartPoint().STY.Value
                                                                                  , segment.STEndPoint().STX.Value
                                                                                  , segment.STEndPoint().STY.Value
                                                                                  , segTiles
                                                                                  , isFirstSegment
                                                                                  , true);

                    // Get elevation for each point
                    this.GetElevationData(ref intersections, adjacentGeoTiffs, segTiles, interpolator);

                    // Add to output list
                    geoPoints.AddRange(intersections);

                    isFirstSegment = false;
                }
                //Debug.WriteLine(adjacentGeoTiffs.Count);
            }  // Ensures all geotifs are properly closed

            return(geoPoints);
        }