[OpenLayers-Users] OpenLayers Question: Google Physical
Projections and epsg:26915
Paul Spencer
pagameba at gmail.com
Sat Jun 28 17:47:54 EDT 2008
I would personally use one of Richard's methods, although you should
note that you would be using 26915 where he uses 4326 in the examples
below. 29615 is a standard EPSG code that is normally in the postgis
spatial reference system if you have initialized your database in the
standard way, so you shouldn't have any problems.
There is another option which would allow you to use OpenLayers to do
the conversion, you need to include the proj4js script in your web
page and define the UTM projection for 26915 appropriately, then you
could convert your maxExtent there.
The home of proj4js is http://trac.osgeo.org/proj4js/ where you can
download (actually get from svn) the latest version - you just need
this file:
https://svn.codehaus.org/mapbuilder/cscs/trunk/proj4js/lib/proj4js-combined.js
The proj4js definition of you projection is found at:
http://spatialreference.org/ref/epsg/26915/proj4js/
The final result in your original example would look like:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OpenLayers Example</title>
<!-- <script src="http://www.openlayers.org/api/OpenLayers.js"></
script> -->
<script src="http://localhost/_common//OpenLayers-2.6/
OpenLayers.js"></script>
<script src="http://localhost/_common//proj4js-combined.js"></
script>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAytPEybOjkPfSINF9aqMnSRRV_Z48x51l4m6KiJWs2Yue7BruuxS9q420SXqAbRhYk8GzmgwCugf2Fw
"
type="text/javascript"></script>
<script type="text/javascript">
var map = null;
function init(){
Proj4js.defs["EPSG:26915"] = "+proj=utm +zone=15
+ellps=GRS80 +datum=NAD83 +units=m +no_defs ";
var mapProj = new OpenLayers.Projection('EPSG:900913');
var utmProj = new OpenLayers.Projection('EPSG:26915');
var displayProj = new OpenLayers.Projection('EPSG:4326');
var bounds = new
OpenLayers.Bounds(184056.505,4809728.25,767381.245,5478975.75);
bounds.transform(utmProj, mapProj);
map = new OpenLayers.Map(
'map',
{
maxResolution: 'auto',
maxExtent: bounds,
projection: mapProj,
displayProjection: displayProj
}
);
var ol_ms = new OpenLayers.Layer.MapServer(
"Mapserver Untiled"
, "http://localhost/cgi-bin/mapserv.exe?map=C:\\ms4w\
\Apache\\htdocs\\ol\\map.map"
, {layers: 'state'}
, {singleTile: true}
);
map.addLayer(ol_ms);
var gmap = new OpenLayers.Layer.Google(
"Google Streets"
, {sphericalMercator: true}
);
map.addLayer(gmap);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.LayerSwitcher());
}
</script>
</head>
<body onload="init()">
<div id="map" class="smallmap" style="width:400;height:300"></div>
</body>
</html>
Cheers
Paul
On 28-Jun-08, at 4:02 PM, Richard Duivenvoorde wrote:
> Hi Matthew,
> I don't know the OS your running, but there is the commandline util
> cs2cs in the 'proj'-package.
> If you install proj in any debian(-derivative) or ms4w/fwtools on
> windows, you can do for example the following to 'cast' one x,y to
> another:
>
> C:\ms4w>cs2cs +init=epsg:4326 +to +init=epsg:28992
> this will wait for a line of input of two points.
> So if you follow with:
> 5.172167 52.245417
> it will give:
> 140313.91 473062.48 -43.21
>
> you can also feed it a list/file with x,y-pairs, or do some
> formatting:
> cs2cs +init=epsg:900913 +to +init=epsg:4326 -f "%.2f"
> 500738 6859019
> 4.50 52.32 0.00
>
> Another option is to use the spatial functions of a postgres/postgis
> db
> if you have that laying around,
> eg. tranform from a 4326 point to a 28992 point:
> SELECT AsText(Transform(GeomFromText('POINT(5.172167 52.245417)',
> 4326),
> 28992))
> or the other way around
> SELECT AsText(Transform(GeomFromText('POINT(140313.905612639
> 473062.480785896)', 28992), 4326))
>
> HTH,
> Regards,
> Richard Duivenvoorde
>
> ps, both options above will only work when you have the right epsg
> codes
> in your proj/postgis configuration
>
> Matthew Pettis wrote:
>> Thanks Paul for your response
>> (http://openlayers.org/pipermail/users/2008-June/006474.html).
>>
>> Truth is, my bounds are not in spherical mercator (they are in
>> epsg:26915), so i will need to convert them. If you, in addition,
>> happen to know some examples of casting bounds from one projection to
>> another, I'd appreciate that as well.
>>
>> Thanks again,
>> Matt
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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
More information about the Users
mailing list