Revision 41342
trunk/org.gvsig.desktop/pom.xml | ||
---|---|---|
2519 | 2519 |
<gvsig.install.plugin.package>true</gvsig.install.plugin.package> |
2520 | 2520 |
|
2521 | 2521 |
<!-- External project versions --> |
2522 |
<gvsig.tools.version>3.0.23</gvsig.tools.version>
|
|
2522 |
<gvsig.tools.version>3.0.24</gvsig.tools.version>
|
|
2523 | 2523 |
<gvsig.about.version>1.0.0</gvsig.about.version> |
2524 | 2524 |
<gvsig.proj.version>1.0.1</gvsig.proj.version> |
2525 | 2525 |
<gvsig.projection.api.version>2.0.15</gvsig.projection.api.version> |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/feature/FeatureAttributeEmulator.java | ||
---|---|---|
38 | 38 |
public void set(EditableFeature feature, Object value); |
39 | 39 |
|
40 | 40 |
public boolean allowSetting(); |
41 |
|
|
42 |
public String[] getRequiredFieldNames(); |
|
41 | 43 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/DefaultFeatureProvider.java | ||
---|---|---|
173 | 173 |
* @see org.gvsig.fmap.dal.feature.spi.FeatureProvider#getDefaultGeometry() |
174 | 174 |
*/ |
175 | 175 |
public Geometry getDefaultGeometry() { |
176 |
return this.defaultGeometry;
|
|
176 |
return this.defaultGeometry;
|
|
177 | 177 |
} |
178 | 178 |
|
179 | 179 |
/* |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.csv/src/main/java/org/gvsig/fmap/dal/store/csv/CSVStoreProvider.java | ||
---|---|---|
748 | 748 |
|
749 | 749 |
private static final Logger logger = LoggerFactory.getLogger(ToPointEvaluaror.class); |
750 | 750 |
|
751 |
private static final int XNAME = 0; |
|
752 |
private static final int YNAME = 1; |
|
753 |
private static final int ZNAME = 2; |
|
754 |
|
|
751 | 755 |
private final GeometryManager geommgr; |
752 |
private final String xname; |
|
753 |
private final String yname; |
|
754 |
private final String zname; |
|
756 |
private final String[] fieldNames; |
|
755 | 757 |
private final Coercion toDouble; |
756 | 758 |
private final DataType dataType; |
757 | 759 |
private int errorcount = 0; |
758 | 760 |
|
759 | 761 |
public PointAttributeEmulator(String[] pointDimensionNames) { |
760 |
this.xname = pointDimensionNames[0]; |
|
761 |
this.yname = pointDimensionNames[1]; |
|
762 | 762 |
if ( pointDimensionNames.length > 2 ) { |
763 |
this.zname = pointDimensionNames[2]; |
|
763 |
this.fieldNames = new String[3]; |
|
764 |
this.fieldNames[ZNAME] = pointDimensionNames[2]; |
|
764 | 765 |
} else { |
765 |
this.zname = null;
|
|
766 |
this.fieldNames = new String[2];
|
|
766 | 767 |
} |
768 |
this.fieldNames[XNAME] = pointDimensionNames[0]; |
|
769 |
this.fieldNames[YNAME] = pointDimensionNames[1]; |
|
767 | 770 |
this.geommgr = GeometryLocator.getGeometryManager(); |
768 | 771 |
DataTypesManager datatypeManager = ToolsLocator.getDataTypesManager(); |
769 | 772 |
|
... | ... | |
773 | 776 |
|
774 | 777 |
public Object get(Feature feature) { |
775 | 778 |
try { |
776 |
double x = ((Double) toDouble.coerce(feature.get(xname))).doubleValue(); |
|
777 |
double y = ((Double) toDouble.coerce(feature.get(yname))).doubleValue(); |
|
779 |
Object value = feature.get(this.fieldNames[XNAME]); |
|
780 |
double x = ((Double) toDouble.coerce(value)).doubleValue(); |
|
781 |
double y = ((Double) toDouble.coerce(feature.get(this.fieldNames[YNAME]))).doubleValue(); |
|
778 | 782 |
Point point = geommgr.createPoint(x, y, Geometry.SUBTYPES.GEOM3D); |
779 |
if ( zname != null ) {
|
|
780 |
double z = ((Double) toDouble.coerce(feature.get(zname))).doubleValue();
|
|
783 |
if( this.fieldNames.length>2 ) {
|
|
784 |
double z = ((Double) toDouble.coerce(feature.get(this.fieldNames[ZNAME]))).doubleValue();
|
|
781 | 785 |
point.setCoordinateAt(2, z); |
782 | 786 |
} |
783 | 787 |
return point; |
784 | 788 |
} catch (Exception ex) { |
785 | 789 |
if ( ++errorcount < 5 ) { |
786 | 790 |
logger.warn("[" + errorcount + "] Can't create point in CSV provider. XNAME='" |
787 |
+ xname + "', YNAME='" + yname + "', ZNAME='" + zname + "', feature=" + feature.toString());
|
|
791 |
+ this.fieldNames[XNAME] + "', YNAME='" + this.fieldNames[XNAME] + "' feature=" + feature.toString(),ex);
|
|
788 | 792 |
} |
789 | 793 |
return null; |
790 | 794 |
} |
... | ... | |
800 | 804 |
} else { |
801 | 805 |
point = (Point) value; |
802 | 806 |
} |
803 |
feature.set(xname, point.getX());
|
|
804 |
feature.set(yname, point.getY());
|
|
805 |
if( zname != null ) {
|
|
806 |
feature.set(yname, point.getCoordinateAt(2));
|
|
807 |
feature.set(this.fieldNames[XNAME], point.getX());
|
|
808 |
feature.set(this.fieldNames[YNAME], point.getY());
|
|
809 |
if( this.fieldNames.length>2 ) {
|
|
810 |
feature.set(this.fieldNames[ZNAME], point.getCoordinateAt(2));
|
|
807 | 811 |
} |
808 | 812 |
} |
809 | 813 |
|
810 | 814 |
public boolean allowSetting() { |
811 | 815 |
return true; |
812 | 816 |
} |
817 |
|
|
818 |
public String[] getRequiredFieldNames() { |
|
819 |
return this.fieldNames; |
|
820 |
} |
|
821 |
|
|
822 |
|
|
813 | 823 |
} |
814 | 824 |
|
815 | 825 |
static class ToPointEvaluaror extends AbstractEvaluator { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultEditableFeatureType.java | ||
---|---|---|
249 | 249 |
if( attr.getEvaluator()!=null ) { |
250 | 250 |
this.hasEvaluators = true; |
251 | 251 |
} |
252 |
if( attr.getFeatureAttributeEmulator()!=null ) { |
|
253 |
this.hasEmulators = true; |
|
254 |
} |
|
252 | 255 |
if( this.defaultGeometryAttributeName == null && attr.getType() == DataTypes.GEOMETRY ) { |
253 | 256 |
this.defaultGeometryAttributeName = attr.getName(); |
254 | 257 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeature.java | ||
---|---|---|
290 | 290 |
} |
291 | 291 |
|
292 | 292 |
public Envelope getDefaultEnvelope() { |
293 |
return this.data.getDefaultEnvelope(); |
|
293 |
Envelope envelope = this.data.getDefaultEnvelope(); |
|
294 |
if( envelope == null ) { |
|
295 |
Geometry geom = this.getDefaultGeometry(); |
|
296 |
envelope = geom.getEnvelope(); |
|
297 |
} |
|
298 |
return envelope; |
|
294 | 299 |
} |
295 | 300 |
|
296 | 301 |
public Geometry getDefaultGeometry() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureType.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
import java.lang.ref.WeakReference; |
27 | 27 |
import java.util.ArrayList; |
28 |
import java.util.Arrays; |
|
28 | 29 |
import java.util.Collections; |
30 |
import java.util.HashSet; |
|
29 | 31 |
import java.util.Iterator; |
30 | 32 |
import java.util.List; |
33 |
import java.util.Set; |
|
31 | 34 |
|
32 | 35 |
import org.cresques.cts.IProjection; |
33 | 36 |
|
... | ... | |
36 | 39 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
37 | 40 |
import org.gvsig.fmap.dal.feature.Feature; |
38 | 41 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
39 |
import org.gvsig.fmap.dal.feature.FeatureRule;
|
|
42 |
import org.gvsig.fmap.dal.feature.FeatureAttributeEmulator;
|
|
40 | 43 |
import org.gvsig.fmap.dal.feature.FeatureRules; |
41 | 44 |
import org.gvsig.fmap.dal.feature.FeatureType; |
42 |
import org.gvsig.fmap.dal.feature.exception.ValidateFeaturesException; |
|
43 | 45 |
import org.gvsig.tools.dynobject.DynClass; |
44 | 46 |
import org.gvsig.tools.dynobject.DynField; |
45 | 47 |
import org.gvsig.tools.dynobject.DynMethod; |
... | ... | |
59 | 61 |
|
60 | 62 |
private DefaultFeatureRules rules; |
61 | 63 |
protected boolean hasEvaluators; |
64 |
protected boolean hasEmulators; |
|
62 | 65 |
protected String defaultGeometryAttributeName; |
63 | 66 |
protected int defaultGeometryAttributeIndex; |
64 | 67 |
protected int defaultTimeAttributeIndex; |
... | ... | |
75 | 78 |
this.id = id; |
76 | 79 |
this.rules = new DefaultFeatureRules(); |
77 | 80 |
this.hasEvaluators = false; |
81 |
this.hasEmulators = false; |
|
78 | 82 |
this.defaultGeometryAttributeName = null; |
79 | 83 |
this.defaultGeometryAttributeIndex = -1; |
80 | 84 |
this.defaultTimeAttributeIndex = -1; |
... | ... | |
108 | 112 |
} |
109 | 113 |
this.defaultGeometryAttributeName = other.defaultGeometryAttributeName; |
110 | 114 |
this.hasEvaluators = other.hasEvaluators; |
115 |
this.hasEmulators = other.hasEmulators; |
|
111 | 116 |
this.rules = (DefaultFeatureRules) other.rules.getCopy(); |
112 | 117 |
this.defaultGeometryAttributeIndex = other.defaultGeometryAttributeIndex; |
113 | 118 |
this.defaultTimeAttributeIndex = other.defaultTimeAttributeIndex; |
... | ... | |
187 | 192 |
return this.hasEvaluators; |
188 | 193 |
} |
189 | 194 |
|
195 |
public boolean hasEmulators() { |
|
196 |
return this.hasEmulators; |
|
197 |
} |
|
198 |
|
|
190 | 199 |
public List getSRSs() { |
191 | 200 |
if (this.srsList == null) { |
192 | 201 |
ArrayList tmp = new ArrayList(); |
... | ... | |
258 | 267 |
private static final long serialVersionUID = 6913732960073922540L; |
259 | 268 |
WeakReference parent; |
260 | 269 |
|
261 |
SubtypeFeatureType(DefaultFeatureType parent, String[] names, String[] constantsNames) |
|
262 |
throws DataException { |
|
263 |
super(parent, false); |
|
264 |
DefaultFeatureAttributeDescriptor attrcopy; |
|
265 |
DefaultFeatureAttributeDescriptor attr; |
|
270 |
SubtypeFeatureType(DefaultFeatureType parent, String[] names, String[] constantsNames) |
|
271 |
throws DataException { |
|
272 |
super(parent, false); |
|
273 |
DefaultFeatureAttributeDescriptor attrcopy; |
|
274 |
DefaultFeatureAttributeDescriptor attr; |
|
275 |
Set attrnames = null; |
|
266 | 276 |
|
267 |
// Copy attributes |
|
268 |
if (names != null && names.length > 0) { |
|
269 |
for (int i = 0; i < names.length; i++) { |
|
270 |
attr = (DefaultFeatureAttributeDescriptor) parent |
|
271 |
.getAttributeDescriptor(names[i]); |
|
272 |
if (attr == null) { |
|
273 |
throw new SubtypeFeatureTypeNameException(names[i], parent |
|
274 |
.getId()); |
|
277 |
// Copy attributes |
|
278 |
if ( names != null && names.length > 0 ) { |
|
279 |
attrnames = new HashSet(); |
|
280 |
attrnames.addAll(Arrays.asList(names)); |
|
281 |
if ( parent.hasEmulators ) { |
|
282 |
for ( int i = 0; i < parent.size(); i++ ) { |
|
283 |
attr = (DefaultFeatureAttributeDescriptor) parent.getAttributeDescriptor(i); |
|
284 |
FeatureAttributeEmulator emulator = attr.getFeatureAttributeEmulator(); |
|
285 |
if ( emulator != null ) { |
|
286 |
String ss[] = emulator.getRequiredFieldNames(); |
|
287 |
if ( ss != null ) { |
|
288 |
attrnames.addAll(Arrays.asList(ss)); |
|
289 |
} |
|
275 | 290 |
} |
276 |
attrcopy = new DefaultFeatureAttributeDescriptor(attr); |
|
277 |
this.add(attrcopy); |
|
278 |
attrcopy.index = i; |
|
279 | 291 |
} |
280 |
} else { |
|
281 |
for( int i=0; i<parent.size(); i++ ) { |
|
282 |
attr = (DefaultFeatureAttributeDescriptor) parent.getAttributeDescriptor(i); |
|
283 |
attrcopy = new DefaultFeatureAttributeDescriptor(attr); |
|
284 |
this.add(attrcopy); |
|
285 |
attrcopy.index = i; |
|
286 |
} |
|
287 | 292 |
} |
293 |
Iterator it = attrnames.iterator(); |
|
294 |
int i = 0; |
|
295 |
while ( it.hasNext() ) { |
|
296 |
String name = (String) it.next(); |
|
297 |
attr = (DefaultFeatureAttributeDescriptor) parent |
|
298 |
.getAttributeDescriptor(name); |
|
299 |
if ( attr == null ) { |
|
300 |
throw new SubtypeFeatureTypeNameException(name, parent |
|
301 |
.getId()); |
|
302 |
} |
|
303 |
attrcopy = new DefaultFeatureAttributeDescriptor(attr); |
|
304 |
this.add(attrcopy); |
|
305 |
attrcopy.index = i++; |
|
306 |
} |
|
288 | 307 |
|
289 |
// Set the consttants attributes. |
|
290 |
if (constantsNames != null && constantsNames.length > 0) { |
|
291 |
for (int i = 0; i < constantsNames.length; i++) { |
|
292 |
attr = (DefaultFeatureAttributeDescriptor) this.getAttributeDescriptor(constantsNames[i]); |
|
293 |
attr.setConstantValue(true); |
|
308 |
} else { |
|
309 |
for ( int i = 0; i < parent.size(); i++ ) { |
|
310 |
attr = (DefaultFeatureAttributeDescriptor) parent.getAttributeDescriptor(i); |
|
311 |
attrcopy = new DefaultFeatureAttributeDescriptor(attr); |
|
312 |
this.add(attrcopy); |
|
313 |
attrcopy.index = i; |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
// Set the consttants attributes. |
|
318 |
if ( constantsNames != null && constantsNames.length > 0 ) { |
|
319 |
for ( int i = 0; i < constantsNames.length; i++ ) { |
|
320 |
if ( attrnames != null && attrnames.contains(constantsNames[i]) ) { |
|
321 |
continue; |
|
294 | 322 |
} |
323 |
attr = (DefaultFeatureAttributeDescriptor) this.getAttributeDescriptor(constantsNames[i]); |
|
324 |
attr.setConstantValue(true); |
|
295 | 325 |
} |
326 |
} |
|
296 | 327 |
|
297 |
// Add missing pk fiels if any |
|
298 |
if (!parent.hasOID()) { |
|
299 |
Iterator iter = parent.iterator(); |
|
300 |
while (iter.hasNext()) { |
|
301 |
attr = (DefaultFeatureAttributeDescriptor) iter.next(); |
|
302 |
if (attr.isPrimaryKey() |
|
303 |
&& this.getIndex(attr.getName()) < 0) { |
|
304 |
attrcopy = new DefaultFeatureAttributeDescriptor(attr); |
|
305 |
this.add(attrcopy); |
|
306 |
attrcopy.index = this.size() - 1; |
|
307 |
} |
|
308 |
} |
|
309 |
} |
|
328 |
// Add missing pk fiels if any |
|
329 |
if ( !parent.hasOID() ) { |
|
330 |
Iterator iter = parent.iterator(); |
|
331 |
while ( iter.hasNext() ) { |
|
332 |
attr = (DefaultFeatureAttributeDescriptor) iter.next(); |
|
333 |
if ( attr.isPrimaryKey() && this.getIndex(attr.getName()) < 0 ) { |
|
334 |
attrcopy = new DefaultFeatureAttributeDescriptor(attr); |
|
335 |
this.add(attrcopy); |
|
336 |
attrcopy.index = this.size() - 1; |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
310 | 340 |
|
311 |
this.defaultGeometryAttributeIndex = this
|
|
312 |
.getIndex(this.defaultGeometryAttributeName);
|
|
313 |
if (this.defaultGeometryAttributeIndex < 0) {
|
|
314 |
this.defaultGeometryAttributeName = null;
|
|
315 |
}
|
|
316 |
this.parent = new WeakReference(parent);
|
|
317 |
}
|
|
341 |
this.defaultGeometryAttributeIndex = this
|
|
342 |
.getIndex(this.defaultGeometryAttributeName);
|
|
343 |
if ( this.defaultGeometryAttributeIndex < 0 ) {
|
|
344 |
this.defaultGeometryAttributeName = null;
|
|
345 |
}
|
|
346 |
this.parent = new WeakReference(parent);
|
|
347 |
}
|
|
318 | 348 |
|
319 | 349 |
public FeatureType getSubtype(String[] names) throws DataException { |
320 | 350 |
return new SubtypeFeatureType((DefaultFeatureType) this.parent |
Also available in: Unified diff