public static Point ToPoint(this RoadwayLocation location, bool includeSpatialReference = false, int?outSR = null)
        {
            double[]         point = { Convert.ToDouble(location.Longitude), Convert.ToDouble(location.Latitude) };
            SpatialReference sr    = null;

            // Project the point if necessary
            if (outSR.HasValue && outSR != _wkid)
            {
                ProjectionInfo startProj = KnownCoordinateSystems.Geographic.World.WGS1984, endProj = null;
                if (outSR == 3857 || outSR == 102100)
                {
                    endProj = KnownCoordinateSystems.Projected.World.WebMercator;
                    sr      = includeSpatialReference ? new WkidBasedSpatialReference {
                        wkid = outSR.Value
                    } : null;
                }
                if (endProj != null)
                {
                    Reproject.ReprojectPoints(point, null, startProj, endProj, 0, 1);
                }
            }
            else
            {
                sr = includeSpatialReference ? new WkidBasedSpatialReference {
                    wkid = _wkid
                } : null;
            }

            return(new Point
            {
                x = point[0],
                y = point[1],
                spatialReference = sr                 //includeSpatialReference ? _spatialReference : null
            });
        }
예제 #2
0
 public static Dictionary <string, dynamic> ToDictionary(this RoadwayLocation roadwayLocation, string prefix = "")
 {
     return(new Dictionary <string, dynamic> {
         { $"{prefix}Description", roadwayLocation.Description },
         { $"{prefix}RoadName", roadwayLocation.RoadName },
         { $"{prefix}Direction", roadwayLocation.Direction },
         { $"{prefix}MilePost", roadwayLocation.MilePost },
         { $"{prefix}Latitude", roadwayLocation.Latitude },
         { $"{prefix}Longitude", roadwayLocation.Longitude }
     });
 }