[OpenLayers-Users] transform help please

Richard Marsden winwaed at gmail.com
Thu Nov 19 21:50:21 EST 2009


Sorry, my mistake: I misunderstood what you were trying to do.
As Mike says: the compressed script should have the specific definitions for
the different projection types.
As an aside, I've just implemented the "gnom" projection which I shall be
checking in soon (probably later tonight).

Richard

On Thu, Nov 19, 2009 at 1:28 PM, Dash <jimlug at co.clackamas.or.us> wrote:

>
> Thanks for the quick response Richard, but I don't see how I'm
> re-projecting
> raster layers when I'm explicitly specifying coordinates to transform?  I'm
> only using the transformation on coordinates, not the base layers (Google).
>
> Ahhh, I just figured it out.  Here is what I had to do in-order to
> transform
> coordinates from EPSG:2913 (Stateplane) to EPSG:900913.  Within the head
> tag
> I added 2 projCodes (lcc.js and merc.js).
>
> <script src="./proj4js/lib/proj4js.js"></script>
> <script src="./proj4js/lib/proj4js-compressed.js"></script>
> <script src="./proj4js/lib/defs/EPSG2913.js"></script>
> <script src="./proj4js/lib/projCode/lcc.js"></script>
> <script src="./proj4js/lib/projCode/merc.js"></script>
>
> Also, here is my transformation:
>
> var srcProj = new OpenLayers.Projection("EPSG:2913");
> var destProj = new OpenLayers.Projection("EPSG:900913");
> var point = new OpenLayers.LonLat(7662464.286, 614886.646);
> point.transform(srcProj, map.getProjectionObject());
>
> My input coordinates were: 7662464.286, 614886.646
> Transformed coordinates: -13647631.260266263, 5674262.881180859
>
> Works great, at least for now.
>
>
> Richard Marsden wrote:
> >
> > It looks like you are trying to re-project Google raster layers?
> >
> > I thought OpenLayers was only capable of re-projecting vector layers?
> >
> > For example, the following article uses OpenLayers (& Proj4JS) to
> > re-project
> > KML and GeoRSS data (geographic coords, WGS84) to a number of different
> > projections (Mollweide, Behrmann, etc):
> >
> >
> http://www.geowebguru.com/articles/209-how-to-create-an-online-map-with-a-non-mercator-projection-part-2
> >
> >
> > Richard Marsden
> > Winwaed Software Technology LLC
> > http://www.winwaed.com
> > http://www.mapping-tools.com
> > http://www.geowebguruc.om
> >
> >
> > On Thu, Nov 19, 2009 at 12:12 PM, Dash <jimlug at co.clackamas.or.us>
> wrote:
> >
> >>
> >> Aloha Thursday folks,
> >>
> >> I am banging my head against the problem for the last several hours.  I
> >> have
> >> went through numerous examples and utilized OpenLayers tutorial on
> >> reprojecting points without any success.  I've even used the Proj4js
> Wiki
> >> without any help.  Could some please shed some light on what I am doing
> >> wrong?
> >>
> >> Here is the scenario.  I am trying to transform some coordinates from
> >> EPSG:2913 to EPSG:900913.  I've also tried a simplified version using
> >> EPSG:4326 -> EPSG:900913.  Anyway, the transform is not happening for
> >> some
> >> odd reason.  I do have the proj4js library within my code and I have
> >> added
> >> EPSG definition to my /proj4js/lib/def directory.  I am checking if the
> >> projection by using the getUnits function of the projection class within
> >> OpenLayers.  If the units come back null, then the proj4js library is
> >> unavailable.  Why is this?  I'm so confused.  This should be rather
> >> straight
> >> forward.  Anyway, here is some of my code.  Hopefully someone can help
> me
> >> out.  Thanks.
> >>
> >> <head>
> >> <script src="http://openlayers.org/dev/lib/OpenLayers.js"
> >> type="text/javascript"></script>
> >> <script src="./proj4js/lib/proj4js.js"></script>
> >> <script src="proj4js/lib/defs/EPSG2913.js"></script>
> >> <script src="proj4js/lib/defs/EPSG900913.js"></script>
> >> <script src="proj4js/lib/defs/EPSG4326.js"></script>
> >> </head>
> >>
> >> <script type="text/javascript">
> >> var map;
> >> function init(){
> >>        var options = {
> >>                //projection: new OpenLayers.Projection("EPSG:900913"),
> >>     // Map projection
> >>                projection: "EPSG:900913",
> >>                displayProjection: new
> OpenLayers.Projection("EPSG:4326"),
> >>    // Display
> >> projection
> >>                units: "m",
> >>                numZoomLevels: 5,
> >>                maxResolution: 156543.0339,
> >>        maxExtent: new OpenLayers.Bounds(-13698618.8209569,
> >> 5595988.4768255,
> >> -13521569.8682338, 5701506.49106001)
> >>        };
> >>
> >>        // Initiate Map Controls
> >>        map.addControl(new OpenLayers.Control.LayerSwitcher());
> >>        map.addControl(new OpenLayers.Control.MousePosition());
> >>
> >>        // Create Google Mercator Layers
> >>        var gmap = new OpenLayers.Layer.Google("Google
> >> Streets",{'sphericalMercator': true, numZoomLevels: 20});
> >>        var gphy = new OpenLayers.Layer.Google("Google Physical",
> >> {'sphericalMercator': true, type: G_PHYSICAL_MAP, numZoomLevels: 20});
> >>    var gsat = new OpenLayers.Layer.Google("Google
> >> Satellite",{'sphericalMercator': true, type: G_SATELLITE_MAP,
> >> numZoomLevels:
> >> 20});
> >>    var ghyb = new OpenLayers.Layer.Google("Google
> >> Hybrid",{'sphericalMercator': true, type: G_HYBRID_MAP, numZoomLevels:
> >> 20});
> >>
> >> map.addLayers([gmap, gphy, gsat, ghyb]);
> >>
> >> var srcProj = new OpenLayers.Projection("EPSG:4326");
> >> alert(srcProj.getUnits());
> >> var point = new OpenLayers.LonLat(-71, 42);
> >> point.transform(srcProj, map.getProjectionObject());
> >>
> >> if(point.transformed)
> >>        {
> >>                alert("point already transformed");
> >>        }
> >>
> >> Proj4js.transform(srcProj, map.getProjectionObject(), point);
> >>
> >> Any suggestions would be greatly appreciated.  THANKS...
> >> --
> >> View this message in context:
> >> http://n2.nabble.com/transform-help-please-tp4033462p4033462.html
> >> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> >> _______________________________________________
> >> Users mailing list
> >> Users at openlayers.org
> >> http://openlayers.org/mailman/listinfo/users
> >>
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> >
>
> --
> View this message in context:
> http://n2.nabble.com/transform-help-please-tp4033462p4033873.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091119/03b0292b/attachment.html


More information about the Users mailing list