Revision 6281
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/LayersWithGroup.java | ||
---|---|---|
12 | 12 |
import java.util.List; |
13 | 13 |
import java.util.Map; |
14 | 14 |
import org.apache.commons.lang.StringUtils; |
15 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
15 | 16 |
import org.gvsig.fmap.dal.exception.DataException; |
16 | 17 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
17 | 18 |
import org.gvsig.fmap.mapcontext.MapContext; |
... | ... | |
171 | 172 |
|
172 | 173 |
private FLyrVect getLayer(FLayers group, FLyrVect layer) { |
173 | 174 |
FeatureStore store = ((FLyrVect) layer).getFeatureStore(); |
175 |
DataStoreParameters params = ((FLyrVect) layer).getDataStoreParameters(); |
|
174 | 176 |
for (FLayer layer1 : group) { |
175 | 177 |
if( layer1 instanceof FLyrVect ) { |
176 | 178 |
FeatureStore store1 = ((FLyrVect) layer1).getFeatureStore(); |
177 |
if( StringUtils.equals(store1.getFullName(), store.getFullName() )) { |
|
178 |
return (FLyrVect) layer1; |
|
179 |
if( store1==null || store == null ) { |
|
180 |
if( layer.getDataStoreParameters().isTheSameStore(params) ) { |
|
181 |
return (FLyrVect) layer1; |
|
182 |
} |
|
183 |
} else { |
|
184 |
if( StringUtils.equals(store1.getFullName(), store.getFullName() )) { |
|
185 |
return (FLyrVect) layer1; |
|
186 |
} |
|
179 | 187 |
} |
180 | 188 |
} |
181 | 189 |
} |
org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/WizardVCSGisVectorial.java | ||
---|---|---|
12 | 12 |
import org.gvsig.fmap.dal.DataManager; |
13 | 13 |
import org.gvsig.fmap.dal.feature.FeatureType; |
14 | 14 |
import org.gvsig.fmap.dal.store.db.DBStoreParameters; |
15 |
import org.gvsig.fmap.geom.Geometry; |
|
16 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
15 | 17 |
import org.gvsig.fmap.mapcontext.BaseCreateLayerParameters; |
16 | 18 |
import org.gvsig.fmap.mapcontext.MapContext; |
17 | 19 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
... | ... | |
82 | 84 |
FeatureType ft2 = o2.getFeatureType(); |
83 | 85 |
int order1 = (ft1==null)? 0:ft1.getTags().getInt("TOC_Order",0); |
84 | 86 |
int order2 = (ft2==null)? 0:ft2.getTags().getInt("TOC_Order",0); |
85 |
String id1 = String.format("%05d/%s/%s", order1, e1.getFirstCategory(), e1.getLabelOrName());
|
|
86 |
String id2 = String.format("%05d/%s/%s", order2, e2.getFirstCategory(), e2.getLabelOrName());
|
|
87 |
String id1 = String.format("%05d/%02d/%s/%s", order1, getLayerOrderWeight(e1), getCategory(e1), e1.getLabelOrName());
|
|
88 |
String id2 = String.format("%05d/%02d/%s/%s", order2, getLayerOrderWeight(e2), getCategory(e2), e2.getLabelOrName());
|
|
87 | 89 |
return id2.compareTo(id1); |
88 | 90 |
} |
89 | 91 |
}); |
... | ... | |
206 | 208 |
}; |
207 | 209 |
} |
208 | 210 |
|
211 |
private int getLayerOrderWeight(VCSGisEntity entity) { |
|
212 |
|
|
213 |
int type2d = Geometry.TYPES.SURFACE; |
|
214 |
try { |
|
215 |
GeometryType geomtype = entity.getFeatureType().getDefaultGeometryAttribute().getGeomType(); |
|
216 |
type2d = simplifyType(geomtype); |
|
217 |
} catch (Exception e) { |
|
218 |
LOGGER.warn("While getting geo type.", e); |
|
219 |
} |
|
220 |
switch (type2d) { |
|
221 |
case Geometry.TYPES.SURFACE: |
|
222 |
return 2; |
|
223 |
case Geometry.TYPES.CURVE: |
|
224 |
return 1; |
|
225 |
case Geometry.TYPES.POINT: |
|
226 |
return 0; |
|
227 |
default: |
|
228 |
// should not reach this |
|
229 |
return 3; |
|
230 |
} |
|
231 |
|
|
232 |
} |
|
233 |
|
|
234 |
private int simplifyType(GeometryType gt) { |
|
235 |
if (gt.isTypeOf(Geometry.TYPES.POINT) || gt.isTypeOf(Geometry.TYPES.MULTIPOINT)) { |
|
236 |
return Geometry.TYPES.POINT; |
|
237 |
|
|
238 |
} else if (gt.isTypeOf(Geometry.TYPES.CURVE) || gt.isTypeOf(Geometry.TYPES.MULTICURVE)) { |
|
239 |
return Geometry.TYPES.CURVE; |
|
240 |
|
|
241 |
} else if (gt.isTypeOf(Geometry.TYPES.SURFACE) || gt.isTypeOf(Geometry.TYPES.MULTISURFACE)) { |
|
242 |
return Geometry.TYPES.SURFACE; |
|
243 |
|
|
244 |
} |
|
245 |
return Geometry.TYPES.SURFACE; |
|
246 |
} |
|
209 | 247 |
} |
Also available in: Unified diff