gvsig-projects-pool / org.gvsig.lidar.prov / org.gvsig.lidar.prov.common / src / main / java / org / gvsig / lidar / prov / LASFetureSetProvider.java @ 281
History | View | Annotate | Download (4.45 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright ? 2007-2016 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 2
|
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.lidar.prov; |
25 |
|
26 |
import org.gvsig.fmap.dal.exception.DataException; |
27 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
28 |
import org.gvsig.fmap.dal.feature.FeatureType; |
29 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureProviderIterator; |
30 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureSetProvider; |
31 |
import org.gvsig.fmap.dal.feature.spi.AbstractFeatureStoreProvider; |
32 |
import org.gvsig.fmap.dal.feature.spi.FeatureSetProvider; |
33 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
34 |
import org.gvsig.tools.ToolsLocator; |
35 |
import org.gvsig.tools.exception.BaseException; |
36 |
import org.slf4j.Logger; |
37 |
import org.slf4j.LoggerFactory; |
38 |
|
39 |
/**
|
40 |
*
|
41 |
* @author <a href="mailto:cmartinez@scolab.es">Cesar Martinez Izquierdo</a>
|
42 |
*
|
43 |
*/
|
44 |
public class LASFetureSetProvider extends AbstractFeatureSetProvider implements FeatureSetProvider { |
45 |
|
46 |
private static final Logger LOG = LoggerFactory.getLogger(LASFetureSetProvider.class); |
47 |
|
48 |
private static final String regularExpresion = |
49 |
"\\s*ST_intersects[(]\\s*ST_GeomFromText[(]\\s*'([^']*)'\\s*,\\s*'([^']*)'\\s*[)],\\s*(?s).*";
|
50 |
|
51 |
/**
|
52 |
* @param store
|
53 |
* Source of this feature set
|
54 |
* @param query
|
55 |
* Query
|
56 |
* @param featureType
|
57 |
* Featuretype requested
|
58 |
*/
|
59 |
public LASFetureSetProvider(AbstractFeatureStoreProvider store, FeatureQuery query,
|
60 |
FeatureType featureType) { |
61 |
super(store, query, featureType);
|
62 |
} |
63 |
|
64 |
@Override
|
65 |
public boolean canFilter() { |
66 |
return false; |
67 |
} |
68 |
|
69 |
@Override
|
70 |
public boolean canOrder() { |
71 |
return false; |
72 |
} |
73 |
|
74 |
@Override
|
75 |
public boolean canIterateFromIndex() { |
76 |
return true; |
77 |
} |
78 |
|
79 |
@Override
|
80 |
public long getSize() throws DataException { |
81 |
return getStore().getFeatureCount(); // FIXME |
82 |
} |
83 |
|
84 |
@Override
|
85 |
public boolean isEmpty() throws DataException { |
86 |
return getSize() == 0; |
87 |
} |
88 |
|
89 |
@Override
|
90 |
protected AbstractFeatureProviderIterator createIterator(long index) throws DataException { |
91 |
return createFastIterator(index);
|
92 |
} |
93 |
|
94 |
@Override
|
95 |
protected AbstractFeatureProviderIterator createFastIterator(long index) throws DataException { |
96 |
return new LASFastIterator(getStore(), index); |
97 |
} |
98 |
|
99 |
@Override
|
100 |
protected void doDispose() throws BaseException { |
101 |
} |
102 |
|
103 |
class LASFastIterator extends AbstractFeatureProviderIterator { |
104 |
|
105 |
private long index; |
106 |
|
107 |
public LASFastIterator(FeatureStoreProvider storeProvider, long index) |
108 |
throws LASUnsupportedFormatException {
|
109 |
super(storeProvider);
|
110 |
ToolsLocator.getDisposableManager().bind(storeProvider); |
111 |
this.index = index;
|
112 |
} |
113 |
|
114 |
@Override
|
115 |
public void remove() { |
116 |
throw new UnsupportedOperationException(); |
117 |
} |
118 |
|
119 |
@Override
|
120 |
protected Object internalNext() { |
121 |
|
122 |
try {
|
123 |
return ((LASDataStoreProvider)this.getDataStoreProvider()).internalGetFeatureProviderByIndex(index++, getFeatureType()); |
124 |
} catch (DataException e) {
|
125 |
// TODO Auto-generated catch block
|
126 |
e.printStackTrace(); |
127 |
} |
128 |
return null; |
129 |
} |
130 |
|
131 |
@Override
|
132 |
protected boolean internalHasNext() { |
133 |
try {
|
134 |
return index < ((LASDataStoreProvider)this.getDataStoreProvider()).getFeatureCount() ? true : false; |
135 |
} catch (DataException e) {
|
136 |
e.printStackTrace(); |
137 |
} |
138 |
return false; |
139 |
} |
140 |
|
141 |
@Override
|
142 |
protected void doDispose() throws BaseException { |
143 |
ToolsLocator.getDisposableManager().release(getStore()); |
144 |
} |
145 |
} |
146 |
} |