public void Filter(GeoAPI.Geometries.Coordinate coord)
        {
            ProjNet.CoordinateSystems.ICoordinateSystem equalArea =
                (ProjNet.CoordinateSystems.ICoordinateSystem)CoordinateSystemWktReader.Parse(ProjectionUtil.NORTH_AMERICAN_ALBERS_EQUAL_AREA_WKT);
            ProjNet.CoordinateSystems.IGeographicCoordinateSystem latlon =
                (ProjNet.CoordinateSystems.IGeographicCoordinateSystem)CoordinateSystemWktReader.Parse(ProjectionUtil.GCS_WGS84_WKT);
            ICoordinateTransformationFactory ctfac          = new CoordinateTransformationFactory();
            ICoordinateTransformation        transformation =
                ctfac.CreateFromCoordinateSystems(equalArea, latlon);

            double[] newCoords = transformation.MathTransform.Transform(new double[] { coord.X, coord.Y });
            coord.X = newCoords[0];
            coord.Y = newCoords[1];
        }
Beispiel #2
0
        public static ICoordinateSystem Convert(ProjNet.CoordinateSystems.ICoordinateSystem system)
        {
            if (system == null)
            {
                return(null);
            }

            var ret = system as ICoordinateSystem;

            if (ret == null)
            {
                ICoordinateSystemProvider provider = ServiceLocator.Current.GetInstance <ICoordinateSystemProvider>();
                ret = provider.CreateFromWkt(system.WKT);
            }

            return(ret);
        }
        public static Coordinate ConvertDegreesToUTM(ICoordinate coordinate)
        {
            var ctfac = new CoordinateTransformationFactory();

            ProjNet.CoordinateSystems.ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
            int zone = (int)System.Math.Ceiling((coordinate.X + 180) / 6);

            ProjNet.CoordinateSystems.ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, coordinate.Y > 0);
            var trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);

            double[] pUtm = trans.MathTransform.Transform(new[] { coordinate.X, coordinate.Y });

            return(new Coordinate
            {
                X = pUtm[0],
                Y = pUtm[1],
            });
        }
        public void Filter(GeoAPI.Geometries.Coordinate coord)
        {
            // TODO: Handle NotSupportedException for projections so
            // that we can offer the user a solution.
            ProjNet.CoordinateSystems.ICoordinateSystem fromCoordinateSystem =
                (ProjNet.CoordinateSystems.ICoordinateSystem)CoordinateSystemWktReader.Parse(projectionWkt);

            ProjNet.CoordinateSystems.IGeographicCoordinateSystem toLatLon =
                (ProjNet.CoordinateSystems.IGeographicCoordinateSystem)CoordinateSystemWktReader.Parse(SRID_4236);
            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();

            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation transformation =
                ctfac.CreateFromCoordinateSystems(fromCoordinateSystem, toLatLon);

            //ICoordinateTransformation transformation =
            //   ctfac.CreateFromCoordinateSystems()

            double[] newCoords = transformation.MathTransform.Transform(new double[] { coord.X, coord.Y });
            coord.X = newCoords[0];
            coord.Y = newCoords[1];
        }
Beispiel #5
0
    public static ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation Transform2Albers(ProjNet.CoordinateSystems.ICoordinateSystem source)
    {
        if (source == null)
        {
            throw new ArgumentException("Source coordinate system is null");
        }
        if (!(source is IGeographicCoordinateSystem))
        {
            throw new ArgumentException("Source coordinate system must be geographic");
        }

        CoordinateSystemFactory cFac = new CoordinateSystemFactory();

        List <ProjectionParameter> parameters = new List <ProjectionParameter>();

        parameters.Add(new ProjectionParameter("central_meridian", -95));
        parameters.Add(new ProjectionParameter("latitude_of_origin", 50));
        parameters.Add(new ProjectionParameter("standard_parallel_1", 29.5));
        parameters.Add(new ProjectionParameter("standard_parallel_2", 45.5));
        parameters.Add(new ProjectionParameter("false_easting", 0));
        parameters.Add(new ProjectionParameter("false_northing", 0));
        IProjection projection = cFac.CreateProjection("Albers_Conic_Equal_Area", "albers", parameters);

        IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Albers_Conic_Equal_Area",
                                                                                   source as IGeographicCoordinateSystem,
                                                                                   projection, ProjNet.CoordinateSystems.LinearUnit.Metre,
                                                                                   new AxisInfo("East",
                                                                                                AxisOrientationEnum.East),
                                                                                   new AxisInfo("North",
                                                                                                AxisOrientationEnum.
                                                                                                North));

        return(new CoordinateTransformationFactory().CreateFromCoordinateSystems(source, coordsys));
    }