Statistics
| Revision:

root / tags / v2_0_0_Build_2051 / extensions / extGPE-gvSIG / src / org / gvsig / fmap / dal / store / gpe / model / GPEFeature.java @ 38724

History | View | Annotate | Download (3.65 KB)

1
package org.gvsig.fmap.dal.store.gpe.model;
2

    
3
import java.util.LinkedHashMap;
4

    
5
import org.gvsig.fmap.geom.Geometry;
6
import org.gvsig.fmap.geom.GeometryLocator;
7
import org.gvsig.fmap.geom.GeometryManager;
8
import org.gvsig.fmap.geom.exception.CreateGeometryException;
9
import org.gvsig.fmap.geom.primitive.Envelope;
10
import org.slf4j.Logger;
11
import org.slf4j.LoggerFactory;
12

    
13
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
14
 *
15
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
16
 *
17
 * This program is free software; you can redistribute it and/or
18
 * modify it under the terms of the GNU General Public License
19
 * as published by the Free Software Foundation; either version 2
20
 * of the License, or (at your option) any later version.
21
 *
22
 * This program is distributed in the hope that it will be useful,
23
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25
 * GNU General Public License for more details.
26
 *
27
 * You should have received a copy of the GNU General Public License
28
 * along with this program; if not, write to the Free Software
29
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
30
 *
31
 * For more information, contact:
32
 *
33
 *  Generalitat Valenciana
34
 *   Conselleria d'Infraestructures i Transport
35
 *   Av. Blasco Ib??ez, 50
36
 *   46010 VALENCIA
37
 *   SPAIN
38
 *
39
 *      +34 963862235
40
 *   gvsig@gva.es
41
 *      www.gvsig.gva.es
42
 *
43
 *    or
44
 *
45
 *   IVER T.I. S.A
46
 *   Salamanca 50
47
 *   46005 Valencia
48
 *   Spain
49
 *
50
 *   +34 963163400
51
 *   dac@iver.es
52
 */
53
/* CVS MESSAGES:
54
 *
55
 * $Id$
56
 * $Log$
57
 *
58
 */
59
/**
60
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
61
 */
62
public class GPEFeature {
63
        private static final GeometryManager GEOMETRY_MANAGER = GeometryLocator.getGeometryManager();
64
        private static final Logger LOG = LoggerFactory.getLogger(GPEFeature.class);
65
        
66
    private static int idFeature = 0;
67
        private Geometry geometry = null;
68
        private LinkedHashMap elements = null;
69
        private String id = null;
70
        private String name = null;
71
        private String typeName = null;
72
        
73
        public GPEFeature(String id, String name, String typeName) {
74
                this();
75
                this.id = id;                
76
                this.name = name;
77
                this.typeName = typeName;                
78
        }        
79

    
80
        public GPEFeature(){
81
                elements = new LinkedHashMap();                
82
        }
83

    
84
        /**
85
         * @return the id
86
         */
87
        public String getId() {
88
                return id;
89
        }
90

    
91
        /**
92
         * @param id the id to set
93
         */
94
        public void setId(String id) {
95
                this.id = id;
96
        }
97

    
98
        /**
99
         * @return the geometry
100
         */
101
        public Geometry getGeometry() {
102
                if (geometry == null){
103
                    try {
104
                    this.geometry = GEOMETRY_MANAGER.create(Geometry.TYPES.NULL, Geometry.SUBTYPES.GEOM3D);
105
                } catch (CreateGeometryException e) {
106
                    LOG.error("Not possible to create a geometry", e);
107
                }
108
                }
109
            return geometry;
110
        }
111

    
112
        /**
113
         * @param geometry the geometry to set
114
         */
115
        public void setGeometry(Geometry geometry) {
116
                this.geometry = geometry;
117
        }
118

    
119
        /**
120
         * @return the elements
121
         */
122
        public LinkedHashMap getelements() {
123
                return elements;
124
        }
125

    
126
        /**
127
         * @param elements the elements to set
128
         */
129
        public void setElements(LinkedHashMap elements) {
130
                this.elements = elements;
131
        }
132
        
133
        /**
134
         * It adds a new element
135
         * @param element
136
         * The element to add
137
         */
138
        public void addElement(GPEElement element){
139
                elements.put(element.getName(), element);
140
        }
141

    
142
        /**
143
         * @return the name
144
         */
145
        public String getName() {
146
                return name;
147
        }
148

    
149
        /**
150
         * @return the typeName
151
         */
152
        public String getTypeName() {
153
                return typeName;
154
        }
155
        
156
        /**
157
         * Initialize the feature id
158
         */
159
        public static void initIdFeature(){
160
                idFeature = 0;
161
        }
162

    
163
        public Envelope getEnvelope() {
164
                if (geometry == null){
165
                        return null;
166
                }
167
                return geometry.getEnvelope();
168
        }
169
}