001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/io/shpapi/SHPPoint.java $ 002 003 /*---------------- FILE HEADER ------------------------------------------ 004 005 This file is part of deegree. 006 Copyright (C) 2001-2008 by: 007 EXSE, Department of Geography, University of Bonn 008 http://www.giub.uni-bonn.de/deegree/ 009 lat/lon GmbH 010 http://www.lat-lon.de 011 012 This library is free software; you can redistribute it and/or 013 modify it under the terms of the GNU Lesser General Public 014 License as published by the Free Software Foundation; either 015 version 2.1 of the License, or (at your option) any later version. 016 017 This library is distributed in the hope that it will be useful, 018 but WITHOUT ANY WARRANTY; without even the implied warranty of 019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 020 Lesser General Public License for more details. 021 022 You should have received a copy of the GNU Lesser General Public 023 License along with this library; if not, write to the Free Software 024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 025 026 Contact: 027 028 Andreas Poth 029 lat/lon GmbH 030 Aennchenstr. 19 031 53115 Bonn 032 Germany 033 E-Mail: poth@lat-lon.de 034 035 Prof. Dr. Klaus Greve 036 Department of Geography 037 University of Bonn 038 Meckenheimer Allee 166 039 53115 Bonn 040 Germany 041 E-Mail: greve@giub.uni-bonn.de 042 043 044 ---------------------------------------------------------------------------*/ 045 046 package org.deegree.io.shpapi; 047 048 049 import org.deegree.model.spatialschema.ByteUtils; 050 import org.deegree.model.spatialschema.Position; 051 052 /** 053 * Class representig a two dimensional point<BR> 054 * 055 * @version 14.08.2000 056 * @author Andreas Poth 057 * 058 */ 059 public class SHPPoint extends SHPGeometry { 060 061 public double x; 062 public double y; 063 064 public SHPPoint() {} 065 066 /** 067 * constructor: gets a stream and the start index <BR> 068 * of point on it <BR> 069 */ 070 public SHPPoint(byte[] recBuf, int xStart) { 071 072 super(recBuf); 073 074 //get x out of recordbuffer 075 this.x = ByteUtils.readLEDouble(recBuffer, xStart); 076 //get y out of recordbuffer 077 this.y = ByteUtils.readLEDouble(recBuffer, xStart + 8); 078 079 } 080 081 /** 082 * constructor: creates a SHPPoint from a WKS Geometrie<BR> 083 */ 084 public SHPPoint (Position point) { 085 x = point.getX() ; 086 y = point.getY() ; 087 } 088 089 /** 090 * method: writeSHPPoint: writes a SHPPoint Objekt to a recBuffer <BR> 091 */ 092 public void writeSHPPoint (byte [] byteArray, int start) { 093 094 int offset = start; 095 096 // write shape type identifier ( 1 = point ) 097 ByteUtils.writeLEInt(byteArray, offset, 1); 098 099 offset += 4; 100 101 //write x into the recbuffer 102 ByteUtils.writeLEDouble (byteArray, offset, x); 103 104 offset += 8; 105 106 //write y into the recbuffer 107 ByteUtils.writeLEDouble (byteArray, offset, y); 108 109 } 110 111 /** 112 * returns the size of the point shape in bytes<BR> 113 */ 114 public int size() { 115 return 20; 116 } 117 118 public String toString() { 119 120 return "SHPPOINT" + "[" + this.x + "; " + this.y + "]"; 121 122 } 123 124 }