/*---------------- 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.geoma.Envelope; import nl.idgis.giclient.geoma.Geometry; import nl.idgis.giclient.geoma.GeometryTools; import nl.idgis.giclient.geoma.NullGeometry; class nl.idgis.giclient.geoma.Point extends Geometry { private var x:Number; private var y:Number; private var z:Number; function Point(srsName:String, x:Number, y:Number) { super(srsName); this.x = x; this.y = y; } function getGeometries():Array { return new Array(); } function addPoint(point:Point, permanent:Boolean):Void { // EXCEPTION } function addPointN(point:Point, number:Number, permanent:Boolean):Void { // EXCEPTION } function removePoint(point:Point, permanent:Boolean):Void { // EXCEPTION } function setPointXY(x:Number, y:Number):Void { // EXCEPTION } function move(dx:Number, dy:Number, permanent:Boolean):Void { x += dx; y += dy; geometryEventDispatcher.changeGeometry(this, permanent); getMostSuperGeometry().geometryEventDispatcher.changeGeometry(this, false); // TODO event model } function setXY(x:Number, y:Number, permanent:Boolean):Void { this.x = x; this.y = y; geometryEventDispatcher.changeGeometry(this, permanent); getMostSuperGeometry().geometryEventDispatcher.changeGeometry(this, false); // TODO event model } function setX(x:Number, permanent:Boolean):Void { this.x = x; geometryEventDispatcher.changeGeometry(this, permanent); } function getX():Number { return x; } function setY(y:Number, permanent:Boolean):Void { this.y = y; geometryEventDispatcher.changeGeometry(this, permanent); } function getY():Number { return y; } function getCoords():Array { return new Array(this); } function getCenterPoint():Point { var centerPoint:Point = new Point(srsName, x, y); return centerPoint; } function getNearestPoint(point:Point):Point { return this; } function getEnvelope():Envelope { return new Envelope(srsName, x, y, x, y); } function clip(envelope:Envelope):Geometry { if (GeometryTools.isWithin(this, envelope)) { return clone(); } return new NullGeometry(); } function clone():Geometry { return new Point(srsName, x, y); } function toString():String { return "Point (" + x + "," + y + ")"; } function getDistance(point:Point):Number { var dx:Number = x - point.getX(); var dy:Number = y - point.getY(); var distance:Number = Math.sqrt((dx * dx) + (dy * dy)); return distance; } function equals(point:Point):Boolean { if ((x == point.getX()) && (y == point.getY())) { return true; } return false; } }