Revision 16396 trunk/libraries/libTopology/src/org/gvsig/topology/Topology.java
Topology.java | ||
---|---|---|
57 | 57 |
import java.util.List; |
58 | 58 |
import java.util.Map; |
59 | 59 |
|
60 |
import org.apache.log4j.Logger; |
|
60 | 61 |
import org.cresques.cts.IProjection; |
61 | 62 |
import org.gvsig.topology.topologyrules.MustBeLargerThanClusterTolerance; |
62 | 63 |
|
... | ... | |
93 | 94 |
public class Topology extends FLayers implements ITopologyStatus, ITopologyErrorContainer { |
94 | 95 |
|
95 | 96 |
|
97 |
private static Logger logger = Logger.getLogger(Topology.class.getName()); |
|
96 | 98 |
/** |
97 | 99 |
* cluster tolerance of the topology |
98 | 100 |
*/ |
... | ... | |
136 | 138 |
*/ |
137 | 139 |
private ITopologyErrorContainer errorContainer; |
138 | 140 |
|
139 |
/** |
|
140 |
* List of error fids that has been marked as exceptions |
|
141 |
* |
|
142 |
* This allows to have a track of the exceptions. |
|
143 |
*/ |
|
144 |
// private List<String> topologyErrorExceptions; |
|
145 |
|
|
146 | 141 |
|
147 | 142 |
/** |
148 | 143 |
* Map that relates a FLyrVect of the Topology with its rank (weight when we |
... | ... | |
154 | 149 |
* Numerical identifier for rules of a topology |
155 | 150 |
*/ |
156 | 151 |
private int ruleId = 0; |
157 |
|
|
152 |
|
|
158 | 153 |
/** |
159 | 154 |
* Default constructor for a topology as a FLayers |
160 | 155 |
* |
... | ... | |
177 | 172 |
layerRanks = new HashMap<FLyrVect, XYZLayerRank>(); |
178 | 173 |
} |
179 | 174 |
|
175 |
|
|
180 | 176 |
/** |
181 |
* Constructor |
|
182 |
* |
|
183 |
* @param clusterTolerance |
|
184 |
* @param maxNumberOfErrors |
|
177 |
* private default constructor. Only used by static method |
|
178 |
* create from xml |
|
185 | 179 |
*/ |
186 |
public Topology(double clusterTolerance, int maxNumberOfErrors, ITopologyErrorContainer errorContainer) {
|
|
187 |
this(null, null, clusterTolerance, maxNumberOfErrors, errorContainer);
|
|
180 |
private Topology(MapContext mapContext, FLayers layers){
|
|
181 |
this(mapContext, layers, 0d, 1000, new SimpleTopologyErrorContainer());
|
|
188 | 182 |
} |
183 |
|
|
184 |
|
|
185 |
/** |
|
186 |
* Creates a topology from its XML representation |
|
187 |
* @param xmlEntity |
|
188 |
* @return |
|
189 |
*/ |
|
190 |
public static Topology createFromXML(MapContext mapContext, XMLEntity xmlEntity){ |
|
191 |
FLayers rootLyr = mapContext.getLayers(); |
|
192 |
Topology solution = new Topology(mapContext, rootLyr); |
|
193 |
|
|
194 |
try { |
|
195 |
solution.setXMLEntity(xmlEntity); |
|
196 |
} catch (XMLException e) { |
|
197 |
logger.error("Error al reconstruir la topologia desde fichero xml", e); |
|
198 |
} |
|
199 |
return solution; |
|
200 |
} |
|
189 | 201 |
|
190 | 202 |
/** |
191 | 203 |
* Changes the cluster tolerance of the topology |
... | ... | |
396 | 408 |
this.xyRank = xyRank; |
397 | 409 |
this.zRank = zRank; |
398 | 410 |
} |
411 |
|
|
412 |
XYZLayerRank(){} |
|
399 | 413 |
|
400 | 414 |
public String getClassName() { |
401 | 415 |
return this.getClass().getName(); |
... | ... | |
836 | 850 |
xml.putProperty("status", status); |
837 | 851 |
xml.putProperty("maxNumberOfErrors", maxNumberOfErrors); |
838 | 852 |
|
839 |
/* |
|
840 |
* podemos tener problemas si los child de Topology no se agrupan l?gicamente. |
|
841 |
* (si se cambia el orden de los items en el xml, se perder?a la l?gica). |
|
842 |
* FIXME Crear clases internas RuleCollection, ClusterRuleCollection, DirtyZonesCollection |
|
843 |
* |
|
844 |
* */ |
|
845 |
|
|
846 | 853 |
int numberOfTopologyRules = rules.size(); |
847 | 854 |
xml.putProperty("numberOfTopologyRules", numberOfTopologyRules); |
848 | 855 |
for(int i = 0; i < numberOfTopologyRules; i++){ |
... | ... | |
894 | 901 |
super.setXMLEntity(xml); |
895 | 902 |
|
896 | 903 |
//FIXME Cambiar el uso de childrenCount por el empleo de propiedades |
897 |
int childrenCount = 0; |
|
904 |
int numLayers = this.getLayersCount(); |
|
905 |
int numProperties = this.getExtendedProperties().size(); |
|
898 | 906 |
|
907 |
int childrenCount = numLayers + numProperties; |
|
908 |
|
|
899 | 909 |
if(xml.contains("clusterTolerance")) |
900 | 910 |
{ |
901 | 911 |
this.clusterTolerance = xml.getDoubleProperty("clusterTolerance"); |
... | ... | |
915 | 925 |
{ |
916 | 926 |
int numberOfTopologyRules = xml.getIntProperty("numberOfTopologyRules"); |
917 | 927 |
for(int i = 0; i < numberOfTopologyRules; i++){ |
918 |
XMLEntity ruleXML = xml.getChild(childrenCount); |
|
919 |
childrenCount++; |
|
928 |
XMLEntity ruleXML = xml.getChild(childrenCount++); |
|
920 | 929 |
ITopologyRule rule = TopologyRuleFactory.createFromXML(this, ruleXML); |
921 | 930 |
this.rules.add(rule); |
922 | 931 |
} |
... | ... | |
926 | 935 |
if(xml.contains("numberOfClusterRules")){ |
927 | 936 |
int numberOfClusterRules = xml.getIntProperty("numberOfClusterRules"); |
928 | 937 |
for(int i = 0; i < numberOfClusterRules; i++){ |
929 |
XMLEntity ruleXML = xml.getChild(childrenCount); |
|
930 |
childrenCount++; |
|
938 |
XMLEntity ruleXML = xml.getChild(childrenCount++); |
|
931 | 939 |
MustBeLargerThanClusterTolerance rule = (MustBeLargerThanClusterTolerance)TopologyRuleFactory.createFromXML(this, ruleXML); |
932 | 940 |
this.clusterToleranceRules.add(rule); |
933 | 941 |
} |
... | ... | |
936 | 944 |
if(xml.contains("numberOfDirtyZones")){ |
937 | 945 |
int numberOfDirtyZones = xml.getIntProperty("numberOfDirtyZones"); |
938 | 946 |
for(int i = 0; i < numberOfDirtyZones; i++){ |
939 |
XMLEntity dirtyZoneXml = xml.getChild(childrenCount); |
|
940 |
childrenCount++; |
|
947 |
XMLEntity dirtyZoneXml = xml.getChild(childrenCount++); |
|
941 | 948 |
double x = dirtyZoneXml.getDoubleProperty("extent"+i+"X"); |
942 | 949 |
double y = dirtyZoneXml.getDoubleProperty("extent"+i+"Y"); |
943 | 950 |
double w = dirtyZoneXml.getDoubleProperty("extent"+i+"W"); |
... | ... | |
950 | 957 |
|
951 | 958 |
|
952 | 959 |
|
953 |
XMLEntity errorContainerXML = xml.getChild(childrenCount); |
|
960 |
XMLEntity errorContainerXML = xml.getChild(childrenCount++);
|
|
954 | 961 |
if(errorContainerXML != null) |
955 | 962 |
{ |
956 | 963 |
this.errorContainer = TopologyPersister.createErrorContainerFromXML(errorContainerXML); |
957 | 964 |
} |
958 |
childrenCount++; |
|
959 | 965 |
|
960 |
|
|
961 |
Iterator<XYZLayerRank> xyzRankIterator = layerRanks.values().iterator(); |
|
962 |
while(xyzRankIterator.hasNext()){ |
|
963 |
XYZLayerRank layerRank = xyzRankIterator.next(); |
|
964 |
XMLEntity entity = layerRank.getXMLEntity(); |
|
965 |
xml.addChild(entity); |
|
966 |
|
|
967 |
} |
|
968 |
|
|
966 |
if(xml.contains("numberOfRanks")){ |
|
967 |
int numberOfRanks = xml.getIntProperty("numberOfRanks"); |
|
968 |
for(int i = 0; i < numberOfRanks; i++){ |
|
969 |
XMLEntity xmlRank = xml.getChild(childrenCount++); |
|
970 |
XYZLayerRank rank = new XYZLayerRank(); |
|
971 |
rank.setXMLEntity(xmlRank); |
|
972 |
} |
|
973 |
} |
|
969 | 974 |
} |
970 | 975 |
|
971 | 976 |
public int getNumberOfExceptions() { |
Also available in: Unified diff