/*---------------- FILE HEADER --------------------------------------- This file is part of Geoide. Copyright (C) 2005-2006 by: IDgis B.V. http://www.idgis.nl This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: Herman Assink IDgis bv P.O. Box 15 7450 AA Holten The Netherlands E-Mail: herman.assink@idgis.nl * @version 1.4.0 * @author IDgis team * ------------------------------------------------------------------------*/ import nl.idgis.giclient.actions.Action; import nl.idgis.giclient.Ruler; import nl.idgis.giclient.geoma.Point; import nl.idgis.giclient.geoma.GMLFactory; import nl.idgis.giclient.io.XMLServer; import nl.idgis.giclient.webserviceconnector.giconnector.GIConnector; import nl.idgis.giclient.io.XMLResponseListener; import nl.idgis.giclient.io.XMLResponse; import nl.idgis.giclient.util.Strings; class nl.idgis.giclient.actions.ZoomToXYAction extends Action implements XMLResponseListener { private var actionObject : Object; public function ZoomToXYAction(ruler:Ruler, actionObject:Object){ this.ruler = ruler; this.actionObject = actionObject; } public function doAction(){ var x:Number = actionObject.getX(); var y:Number = actionObject.getY(); checkCoordinates(); } private function checkCoordinates():Void{ var error:Boolean = false; if(actionObject.getCrs() == null){ error = true; actionObject.state(//"Kies eerst een coordinaat systeem !"); Strings.getFile("Geoide").getString("ChooseCoordinateSystem")); } else { if(actionObject.getX() ==""){ error = true; actionObject.state(//"Voer de X coordinaat in !"); Strings.getFile("Geoide").getString("EnterX")); } else { if(actionObject.getY()==""){ error = true; actionObject.state(//"Voer de Y coordinaat in !"); Strings.getFile("Geoide").getString("EnterY")); } } } if(!error){ var xInput:Number = Number(actionObject.getX()); var yInput:Number = Number(actionObject.getY()); var crs:String = actionObject.getCrs(); var mapSrs:String = ruler.getGIS().getActiveMap().getSRS(); var mapPoint:Point = new Point(crs,xInput,yInput); if(crs!=mapSrs){ transformPoint(mapPoint,crs, mapSrs); } else { ruler.getGIS().zoomToXY(xInput,yInput); } } } private function transformPoint(point:Point,fromSrs:String,toSrs:String ):Void{ //var mapViewer:MapViewer = _root.mapViewer; var geometryNode:XMLNode = GMLFactory.createGeometryNode("transformPoint", point,fromSrs); var geometryXML:XML = new XML(); geometryXML.appendChild(geometryNode.firstChild); var serverRequest:String = "request=Transform&toSRS=" + toSrs; //var xmlServer:XMLServer = mapViewer.ruler.getGIClientConfig().getXMLServer(); var xmlServer:XMLServer = new XMLServer(GIConnector(ruler.getGIS().getTransformConnector()).getURL()); xmlServer.postAndLoad(geometryXML, this, serverRequest, null); } function onLoadXMLResponse(xmlResponse:XMLResponse):Void { //var mapViewer:MapViewer = _root.mapViewer; var point:Point = Point(GMLFactory.parseGML(xmlResponse.firstChild)); var xInput:Number = point.getX(); var yInput:Number = point.getY(); ruler.getGIS().zoomToXY(xInput,yInput); } }