[OpenLayers-Users] Gauss-Boaga track shifted to North!

Riggi Valerio vash.84 at virgilio.it
Mon Nov 12 01:09:59 PST 2012


Hi, I'm trying to display a KML track from WGS84 to Gauss-Boaga using 
the proj4js library but the track result shifted like 500 meters 
north...what is wrong?

*This is the page*: http://www.intornoamessina.it/tracking/image-layer2.html

*And this is the code*:

<style>
.olControlAttribution { bottom: 0px!important }
</style>

<script type="text/javascript" src="OpenLayers.js"></script>

<script type="text/javascript" 
src="proj4js/lib/proj4js-compressed.js"></script>
<script type="text/javascript" src="proj4js/lib/projCode/tmerc.js"></script>
<script type="text/javascript" src="proj4js/lib/projCode/merc.js"></script>
<script type="text/javascript" src="proj4js/lib/defs/EPSG3004.js"></script>
<script type="text/javascript" 
src="proj4js/lib/defs/EPSG900913.js"></script>

<script type="text/javascript">
     Proj4js.libPath = "./proj4js/lib/";
</script>


<script type="text/javascript">

/* area of interest
EPSG:3004
GEOMETRYCOLLECTION(POLYGON((2556348.9846319 4227924.438,2563754.843 
4227924.438,2563754.843 4233595.0653626,2556348.9846319 
4233595.0653626,2556348.9846319 4227924.438)))

EPSG:4326
GEOMETRYCOLLECTION(POLYGON((15.415108753542293 
38.197099410930804,15.499681620107433 38.19676993127058,15.5000312968338 
38.24787310414907,15.415399250825338 38.2482031851047,15.415108753542293 
38.197099410930804)))
*/

var mercator = new OpenLayers.Projection("EPSG:3004"); <!-- Gauss-Boaga -->
var geographic = new OpenLayers.Projection("EPSG:4326"); <!-- WGS84 -->

var map;

function init()
{

     var esriSatellite = new OpenLayers.Layer.ArcGIS93Rest("ESRI 
Satellite", 
"http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/export?f=image",
         {   "format" :'png24',
             "layers" :'show:0'
         },
         {   "isBaseLayer":true,
             "opacity":1,
             "attribution": "Provided by <a 
href=\"http://www.esri.com/software/arcgis/arcgisonline/index.html\" 
target=\"_new\">ESRI</a>",
             "visibility":true
         });

     map = new OpenLayers.Map({
         div: "map",
         projection: mercator,
         maxExtent: new OpenLayers.Bounds(2000000,3900000,3000000,4500000),
         maxScale: 3145, //0.84686783985005,
         layers: [esriSatellite, new OpenLayers.Layer.PointTrack("Tracks", {
                 projection: geographic,
                 strategies: [new OpenLayers.Strategy.Fixed()],
                 protocol: new OpenLayers.Protocol.HTTP({
                     url: "-track.kml",
                     format: new OpenLayers.Format.KML()
                 }),
                 styleMap: new OpenLayers.StyleMap({fillColor: 
"darkred", strokeColor: "red", strokeWidth: 4, strokeOpacity: 0.5, 
pointRadius: 5}),
                 //next two lines have no effect?!
                 //dataFrom: OpenLayers.Layer.PointTrack.TARGET_NODE,
                 //styleFrom: OpenLayers.Layer.PointTrack.TARGET_NODE,
                 eventListeners: {
                     "beforefeaturesadded": function(e) {
                         // group the tracks by fid and create one track for
                         // every fid
                         var fid, points = [], feature;
                         for (var i=0, len=e.features.length; i<len; i++) {
                             feature = e.features[i];
                             if ((fid && feature.fid !== fid) || i === 
len-1) {
                                 this.addNodes(points, {silent: true});
                                 points = [];
                             } else {
                                 points.push(feature);
                             }
                             fid = feature.fid;
                         }
                         return false;
                     }
                 }
             })
         ],
         center: new 
OpenLayers.LonLat(15.4385912418365,38.2424157857895).transform(geographic, 
mercator),
         zoom: 13
     });

     map.addControl(new OpenLayers.Control.Attribution());
     map.addControl(new OpenLayers.Control.LayerSwitcher());
}
</script>

</head>
<body onload="init();">

<p 
style="font-size:20px;font-family:Arial;">OpenLayers.Layer.PointTrack, 
Gauss-Boaga-Projection and proj4js</p>
<div id="map" style="width:768px;height:512px;border:1px solid blue;"></div>
<div>
<a href="http://trac.osgeo.org/proj4js/">proj4js</a> <a 
href="http://trac.osgeo.org/proj4js/" target="_new"><img 
src="http://gis.ibbeck.de/ginfo/apps/OLExamples/index/nw.gif" title="new 
window" border="0"></a>
<a 
href="http://trac.osgeo.org/openlayers/wiki/Documentation/Dev/proj4js">OpenLayers 
and proj4js</a> <a 
href="http://trac.osgeo.org/openlayers/wiki/Documentation/Dev/proj4js" 
target="_new"><img 
src="http://gis.ibbeck.de/ginfo/apps/OLExamples/index/nw.gif" title="new 
window" border="0"></a>
</div>
</body>

Thanks
Valerio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20121112/ad8e69b4/attachment-0001.html>


More information about the Users mailing list