[OpenLayers-Users] OpenLayers.Projection and proj4js.js
Matthew Pettis
matthew.pettis at gmail.com
Sat Jun 28 17:20:13 EDT 2008
Hi,
I'm trying to cast a point in one projection into another, and I think I
have some issues with OpenLayers.Projection. Below is html/javascript code
I'm using and the rendered browser ouput. In this example, I'm trying to
cast the point (184056.505, 4809728.250) in epsg:26915 to epgs:4326. My
expectation is that point p, which is this point in epsg:26915, should
display as something on the order of (-100,43), or something close to that
range. However, as the output shows, the point is not changed. Can someone
explain why?
Thanks,
matt
P.S. - Is there an error in the documentation for the constructor of
OpenLayers.Projection (at:
http://dev.openlayers.org/releases/OpenLayers-2.6/doc/apidocs/files/OpenLayers/Projection-js.html#OpenLayers.Projection.OpenLayers.Projection)?
It says that the constructor takes an object to set parameters, but every
example I see of the constructor is passing a string in the way I am setting
it here. Am I not understanding the documentation conventions correctly, or
is this not correctly or completely documented?
=== html/javascript code ===
<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>
</head>
<body>
<pre>
<script type="text/javascript">
var p = new OpenLayers.Geometry.Point(184056.505, 4809728.250);
var proj_src = new OpenLayers.Projection("EPSG:26915");
var proj_tgt = new OpenLayers.Projection("EPSG:4326");
document.writeln();
document.writeln("Point p [before OpenLayers.Projection.transform]
is: " + p);
OpenLayers.Projection.transform(p,proj_src,proj_tgt);
document.writeln("Point p [after OpenLayers.Projection.transform]
is: " + p);
document.writeln("proj_src is: " + proj_src);
document.writeln();
document.writeln("prj_src walk of properties is:");
document.writeln("------------------------------");
for (prop in proj_src) {
document.writeln(prop + " => " + proj_src[prop]);
};
document.writeln("------------------------------");
</script>
</pre>
</body>
</html>
========================================================================
=== browser rendered output ===
Point p [before OpenLayers.Projection.transform] is: POINT(184056.505
4809728.25)
Point p [after OpenLayers.Projection.transform] is: POINT(184056.505 4809728.25)
proj_src is: EPSG:26915
prj_src walk of properties is:
------------------------------
projCode => EPSG:26915
proj => null
initialize => function (projCode, options) {
OpenLayers.Util.extend(this, options);
this.projCode = projCode;
if (window.Proj4js) {
this.proj = new Proj4js.Proj(projCode);
}
}
getCode => function () {
return this.proj ? this.proj.srsCode : this.projCode;
}
getUnits => function () {
return this.proj ? this.proj.units : null;
}
toString => function () {
return this.getCode();
}
equals => function (projection) {
if (projection && projection.getCode) {
return this.getCode() == projection.getCode();
} else {
return false;
}
}
destroy => function () {
delete this.proj;
delete this.projCode;
}
CLASS_NAME => OpenLayers.Projection
------------------------------
========================================================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080628/351ffd54/attachment.html
More information about the Users
mailing list