problem rendering with coordinate transform

Oct 21, 2011 at 11:00 AM

I have a problem when rendering a shape in EPSG32632 to EPSG900913 (google mercator)

this code in VectorLayer.cs give me !notimplementedexception"

 

 public override void Render(Graphics g, Map map)        {           

if (map.Center == null)             

  throw (new ApplicationException("Cannot render map. View center not specified"));
            g.SmoothingMode = SmoothingMode;           

BoundingBox envelope = map.Envelope; //View to render           

if (CoordinateTransformation != null)            {               

CoordinateTransformation.MathTransform.Invert();               

envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.MathTransform);               

CoordinateTransformation.MathTransform.Invert();            } ...........

 

 

the same if i try to render from  EPSG4326 to EPSG900913

Developer
Oct 21, 2011 at 2:11 PM

CoordinateTransformation.MathTransform.Invert();        throw this kind of exception.

Try using this code to build a 4326 to 900913 projection:

            CoordinateSystemFactory csFac = new CoordinateSystemFactory();
            CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
            IGeographicCoordinateSystem sourceCs = csFac.CreateGeographicCoordinateSystem(
                "WGS 84",
                AngularUnit.Degrees,
                HorizontalDatum.WGS84,
                PrimeMeridian.Greenwich,
                new AxisInfo("north", AxisOrientationEnum.North),
                new AxisInfo("east", AxisOrientationEnum.East));

            List<ProjectionParameter> parameters = new List<ProjectionParameter>();
            parameters.Add(new ProjectionParameter("semi_major", 6378137.0));
            parameters.Add(new ProjectionParameter("semi_minor", 6378137.0));
            parameters.Add(new ProjectionParameter("latitude_of_origin", 0.0));
            parameters.Add(new ProjectionParameter("central_meridian", 0.0));
            parameters.Add(new ProjectionParameter("scale_factor", 1.0));
            parameters.Add(new ProjectionParameter("false_easting", 0.0));
            parameters.Add(new ProjectionParameter("false_northing", 0.0));
            IProjection projection = csFac.CreateProjection("Google Mercator", "mercator_1sp", parameters);
            IProjectedCoordinateSystem targetCs = csFac.CreateProjectedCoordinateSystem(
                "Google Mercator",
                sourceCs,
                projection,
                LinearUnit.Metre,
                new AxisInfo("East", AxisOrientationEnum.East),
                new AxisInfo("North", AxisOrientationEnum.North));
            return ctFac.CreateFromCoordinateSystems(sourceCs, targetCs);

Coordinator
Oct 21, 2011 at 5:46 PM

Hi,

Proj4Net have problem with some projections and inverting them.

In the latest trunk-version of SharpMap you can also se the ReverseCoordinateTransformation on the Layer.

i.e.

Set transformation EPSG32632 to EPSG900913  for CoordinatTransformation and 

EPSG900913 to EPSG32632 av Reverse Coordinate Transformation