svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.shp / src / main / java / org / gvsig / fmap / dal / store / shp / SHPFeatureProvider.java @ 47436
History | View | Annotate | Download (2.35 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2023 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.fmap.dal.store.shp; |
25 |
|
26 |
import org.gvsig.fmap.dal.exception.DataException; |
27 |
import org.gvsig.fmap.dal.exception.ReadRuntimeException; |
28 |
import org.gvsig.fmap.dal.feature.FeatureType; |
29 |
import org.gvsig.fmap.dal.store.dbf.DBFFeatureProvider; |
30 |
import org.gvsig.fmap.geom.Geometry; |
31 |
import org.gvsig.fmap.geom.primitive.Envelope; |
32 |
|
33 |
public class SHPFeatureProvider extends DBFFeatureProvider { |
34 |
|
35 |
public SHPFeatureProvider(SHPStoreProvider store, FeatureType providerFeatureType, FeatureType storeFeatureType) {
|
36 |
super(store, providerFeatureType, storeFeatureType);
|
37 |
} |
38 |
|
39 |
@Override
|
40 |
protected void load() { |
41 |
if (loading || loaded || this.isNew()) { |
42 |
return;
|
43 |
} |
44 |
loading = true;
|
45 |
try {
|
46 |
((SHPStoreProvider)this.store).loadFeatureProviderByIndex(this); |
47 |
} catch (DataException e) {
|
48 |
throw new ReadRuntimeException(getNameForMessages(), this.getOID(), e); |
49 |
} finally {
|
50 |
loading = false;
|
51 |
loaded = true;
|
52 |
} |
53 |
} |
54 |
|
55 |
|
56 |
@Override
|
57 |
public Geometry getDefaultGeometry() {
|
58 |
this.load();
|
59 |
Geometry geom = this.defaultGeometry;
|
60 |
if (geom != null && geom.getProjection() == null) { |
61 |
geom.setProjection(((SHPStoreProvider) this.store).getProjection());
|
62 |
} |
63 |
return geom;
|
64 |
} |
65 |
|
66 |
@Override
|
67 |
public Envelope getDefaultEnvelope() {
|
68 |
return this.envelope; |
69 |
} |
70 |
|
71 |
} |