[OpenLayers-Users] transform help please
Dash
jimlug at co.clackamas.or.us
Thu Nov 19 15:05:04 EST 2009
You are absolutely correct. I was just heading that direction after reading
some more into how proj4js works. I've also noticed that typos are a
killer%-|.
Thanks for everyone's help:handshake: I'm digging this stuff.
Mike Adair wrote:
>
> If that fixed it then all you should need is like this:
>
> <script src="./proj4js/lib/proj4js-compressed.js"></script>
> <script src="./proj4js/lib/defs/EPSG2913.js"></script>
>
> merc.js and lcc.js are included in the proj4js-compressed.js version and
> not in proj4js.js
>
> Mike
>
>
> Dash 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
>>>
>>>
>>>
>>
>>
>
> --
> Michael Adair
> Senior Software Architect
> DM Solutions Group Inc.
>
> Office: (613) 565-5056 x26
> madair at dmsolutions.ca
> http://www.dmsolutions.ca
> http://research.dmsolutions.ca
>
>
> _______________________________________________
> 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-tp4033462p4034082.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list