[fusion-commits] r2184 - in branches/fusion-2.0: layers/MapGuide
widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu Jun 24 13:38:07 EDT 2010
Author: madair
Date: 2010-06-24 17:38:06 +0000 (Thu, 24 Jun 2010)
New Revision: 2184
Modified:
branches/fusion-2.0/layers/MapGuide/MapGuide.js
branches/fusion-2.0/widgets/Measure.js
Log:
re #395: parse WKT to define the projection if the EPSG code is not specified and add a 'geodesic' property to the Measure widget for use with Local coordinate systems
Modified: branches/fusion-2.0/layers/MapGuide/MapGuide.js
===================================================================
--- branches/fusion-2.0/layers/MapGuide/MapGuide.js 2010-06-22 09:40:33 UTC (rev 2183)
+++ branches/fusion-2.0/layers/MapGuide/MapGuide.js 2010-06-24 17:38:06 UTC (rev 2184)
@@ -303,6 +303,16 @@
//set projection units and code if supplied
if (o.epsg != 0) {
this.mapTag.layerOptions.projection = "EPSG:" + o.epsg;
+ } else {
+ if (o.wkt.length > 0) {
+ var wkt = o.wkt;
+ var wktContentRE = /(\w+)\[(.*)\]/;
+ var wktContent = wkt.match(wktContentRE);
+ var wktName = wktContent[2].split(",")[0];
+ wktName = wktName.toUpperCase();
+ this.mapTag.layerOptions.projection = wktName;
+ Proj4js.defs[wktName] = "+proj=identity +"+wkt;
+ }
}
//TODO: consider passing the metersPerUnit value into the framework
//to allow for scaling that doesn't match any of the pre-canned units
Modified: branches/fusion-2.0/widgets/Measure.js
===================================================================
--- branches/fusion-2.0/widgets/Measure.js 2010-06-22 09:40:33 UTC (rev 2183)
+++ branches/fusion-2.0/widgets/Measure.js 2010-06-24 17:38:06 UTC (rev 2184)
@@ -65,6 +65,9 @@
/* Style for the polygon used for area draw */
fillStyle: null,
+ /* Style for the polygon used for area draw */
+ geodesic: true,
+
/* Style for the polygon line used for area draw */
areaStyle: null,
segmentLabels: true,
@@ -75,8 +78,11 @@
this.distPrecision = json.DistancePrecision ? parseInt(json.DistancePrecision[0]) : 4;
this.areaPrecision = json.AreaPrecision ? parseInt(json.AreaPrecision[0]) : 4;
if(json.SegmentLabels){
- this.segmentLabels = (json.SegmentLabels[0].toLowerCase == "true" && json.SegmentLabels[0]) ? true : false;
+ this.segmentLabels = (json.SegmentLabels[0].toLowerCase() == "true" && json.SegmentLabels[0]) ? true : false;
}
+ if(json.Geodesic){
+ this.geodesic = (json.Geodesic[0].toLowerCase() == "false") ? false : true;
+ }
this.sTarget = json.Target ? json.Target[0] : "";
this.sBaseUrl = Fusion.getFusionURL() + 'widgets/Measure/Measure.php';
@@ -288,7 +294,11 @@
from = this.getMap().geoToPix(v[0].x,v[0].y);
to = this.getMap().geoToPix(v[1].x,v[1].y);
at = {x: (from.x + to.x) / 2, y: (from.y + to.y) / 2};
- quantity = geom.getGeodesicLength(proj);
+ if (this.geodesic) {
+ quantity = geom.getGeodesicLength(proj);
+ } else {
+ quantity = geom.getLength();
+ }
//calculate the length in pixels
pixQuantity = Math.sqrt((to.x - from.x) * (to.x - from.x) + (to.y - from.y) * (to.y - from.y));
@@ -303,7 +313,11 @@
var cg = geom.getCentroid();
at = this.getMap().geoToPix(cg.x, cg.y);
- quantity = geom.getGeodesicArea(proj);
+ if (this.geodesic) {
+ quantity = geom.getGeodesicArea(proj);
+ } else {
+ quantity = geom.getArea();
+ }
measureUnits = Fusion.METERS;
if (measureUnits != this.units) {
More information about the fusion-commits
mailing list