예제 #1
0
        public Projector(CoordinateSystem fromCs, CoordinateSystem toCs)
        {
            CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();

            _forwardTransform = ctfac.CreateFromCoordinateSystems(fromCs, toCs);
            _inverseTransform = ctfac.CreateFromCoordinateSystems(toCs, fromCs);
        }
        public SpatialReference createSRSfromWKT(string wkt, ICoordinateSystem source)
        {
            SpatialReference result = null;

            //SetUp coordinate transformation
            ProjNet.CoordinateSystems.CoordinateSystemFactory csf = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
            cs = csf.CreateFromWkt(wkt);
            ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctf = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            ctf.CreateFromCoordinateSystems(source, cs);
            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation ct = ctf.CreateFromCoordinateSystems(cs, source);
            //crear SharpMapSpatialReference usando el coordinateTranformation.
            throw new NotImplementedException();
        }
예제 #3
0
    protected void ddlProjection_SelectedIndexChanged(object sender, EventArgs e)
    {
        //Transform current view to new coordinate system and zoom to the transformed box
        string PreviousProj = ViewState["currentProj"].ToString();
        string SelectedProj = ddlProjection.SelectedValue;

        //Points defining the current view
        Point left   = new Point(myMap.Envelope.Left, myMap.Center.Y);
        Point right  = new Point(myMap.Envelope.Right, myMap.Center.Y);
        Point center = myMap.Center;

        if (PreviousProj != "Pseudo")
        {
            //Transform current view back to geographic coordinates
            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation trans = GetTransform(PreviousProj);
            left = GeometryTransform.TransformPoint(new Point(myMap.Envelope.Left, myMap.Center.Y),
                                                    trans.MathTransform.Inverse());
            right = GeometryTransform.TransformPoint(new Point(myMap.Envelope.Right, myMap.Center.Y),
                                                     trans.MathTransform.Inverse());
            center = GeometryTransform.TransformPoint(myMap.Center, trans.MathTransform.Inverse());
        }
        //If both PreviousSRID and SelectedSRID are projected coordsys, first transform to geographic

        if (SelectedProj == "Pseudo")
        {
            myMap.Center = center;
            myMap.Zoom   = Math.Abs(right.X - left.X);
        }
        else //Project coordinates to new projection
        {
            //Transform back to geographic and over to new projection
            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation trans = GetTransform(SelectedProj);
            left         = GeometryTransform.TransformPoint(left, trans.MathTransform);
            right        = GeometryTransform.TransformPoint(right, trans.MathTransform);
            center       = GeometryTransform.TransformPoint(center, trans.MathTransform);
            myMap.Center = center;
            myMap.Zoom   = Math.Abs(right.X - left.X);
            BoundingBox envelopeGcs = GeometryTransform.TransformBox(myMap.Envelope, trans.MathTransform.Inverse());
            litEnvelopeLatLong.Text = envelopeGcs.ToString();
        }
        GenerateMap();
    }
        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];
        }
        public SpatialReference createSRSfromWKT(string wkttarget, string wktsource)
        {
            ProjNet.CoordinateSystems.CoordinateSystemFactory csf      = new ProjNet.CoordinateSystems.CoordinateSystemFactory();
            ProjNet.CoordinateSystems.ICoordinateSystem       csSource = csf.CreateFromWkt(wktsource);
            ProjNet.CoordinateSystems.ICoordinateSystem       csTarget = csf.CreateFromWkt(wkttarget);
            ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory ctf = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation       ct  = ctf.CreateFromCoordinateSystems(csSource, csTarget);
            SharpMapSpatialReference sr = new SharpMapSpatialReference();

            sr.CoordinateSystem = csSource;
            sr.MathTransform    = ct.MathTransform;
            return(sr);
        }
        public void Filter(GeoAPI.Geometries.Coordinate coord)
        {
            ProjNet.CoordinateSystems.ICoordinateSystem           mercator = getMercatorProjection();
            ProjNet.CoordinateSystems.IGeographicCoordinateSystem latlon   =
                (ProjNet.CoordinateSystems.IGeographicCoordinateSystem)CoordinateSystemWktReader.Parse(SRID_4236);
            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformationFactory ctfac          = new CoordinateTransformationFactory();
            ProjNet.CoordinateSystems.Transformations.ICoordinateTransformation        transformation =
                ctfac.CreateFromCoordinateSystems(latlon, mercator);

            double[] newCoords = transformation.MathTransform.Transform(new double[] { coord.X, coord.Y });
            coord.X = newCoords[0];
            coord.Y = newCoords[1];
        }