Revision 9500
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.topology.lib.api.TopologyLibrary |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyServices.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author jjdelcerro |
|
31 |
*/ |
|
32 |
public interface TopologyServices { |
|
33 |
|
|
34 |
public FeatureStore getFeatureStore(TopologyDataSet dataSet); |
|
35 |
|
|
36 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyReportLine.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
27 |
import org.gvsig.fmap.geom.Geometry; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author jjdelcerro |
|
32 |
*/ |
|
33 |
public interface TopologyReportLine { |
|
34 |
|
|
35 |
public TopologyRule getRule(); |
|
36 |
|
|
37 |
public TopologyDataSet getDataSet1(); |
|
38 |
|
|
39 |
public TopologyDataSet getDataSet2(); |
|
40 |
|
|
41 |
public Geometry getGeometry(); |
|
42 |
|
|
43 |
public Geometry getError(); |
|
44 |
|
|
45 |
public FeatureReference getFeature1(); |
|
46 |
|
|
47 |
public FeatureReference getFeature2(); |
|
48 |
|
|
49 |
public int getPrimitiveNumber1(); |
|
50 |
|
|
51 |
public int getPrimitiveNumber2(); |
|
52 |
|
|
53 |
public boolean isException(); |
|
54 |
|
|
55 |
public String getDescription(); |
|
56 |
|
|
57 |
public String getData(); |
|
58 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyDataSet.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.expressionevaluator.Expression; |
|
27 |
import org.gvsig.fmap.dal.DataStore; |
|
28 |
import org.gvsig.fmap.dal.exception.DataException; |
|
29 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
30 |
import org.gvsig.fmap.dal.feature.Feature; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
32 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
33 |
import org.gvsig.fmap.geom.Geometry; |
|
34 |
import org.gvsig.fmap.geom.SpatialIndex; |
|
35 |
import org.gvsig.json.SupportJson; |
|
36 |
import org.gvsig.tools.util.PropertiesSupport; |
|
37 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
38 |
import org.gvsig.tools.visitor.Visitor; |
|
39 |
|
|
40 |
/** |
|
41 |
* |
|
42 |
* @author jjdelcerro |
|
43 |
*/ |
|
44 |
public interface TopologyDataSet extends PropertiesSupport, SupportJson { |
|
45 |
|
|
46 |
public static interface Operation { |
|
47 |
public void run() throws DataException; |
|
48 |
} |
|
49 |
|
|
50 |
public void setName(String name); |
|
51 |
|
|
52 |
public String getName(); |
|
53 |
|
|
54 |
public void setStore(DataStore store); |
|
55 |
|
|
56 |
public DataStore getStore(); |
|
57 |
|
|
58 |
public FeatureStore getFeatureStore(); |
|
59 |
|
|
60 |
public boolean isThisStore(FeatureStore featureStore); |
|
61 |
|
|
62 |
public int getGeometryType() ; |
|
63 |
|
|
64 |
public void accept(Visitor visitor) throws VisitCanceledException; |
|
65 |
|
|
66 |
public void edit() throws DataException; |
|
67 |
|
|
68 |
public void finishEditing() throws DataException; |
|
69 |
|
|
70 |
public EditableFeature createNewFeature() throws DataException; |
|
71 |
|
|
72 |
public void delete(FeatureReference feature) throws DataException; |
|
73 |
|
|
74 |
public void delete(Feature feature) throws DataException; |
|
75 |
|
|
76 |
public void insert(EditableFeature feature) throws DataException; |
|
77 |
|
|
78 |
public void update(EditableFeature feature) throws DataException; |
|
79 |
|
|
80 |
public long getSize(); |
|
81 |
|
|
82 |
public SpatialIndex getSpatialIndex(); |
|
83 |
|
|
84 |
/** |
|
85 |
* @param geom |
|
86 |
* @return |
|
87 |
* @deprecated use queryFeatures or queryReferences |
|
88 |
*/ |
|
89 |
public Iterable<FeatureReference> query(Geometry geom); |
|
90 |
|
|
91 |
public Iterable<Feature> queryFeatures(Geometry geom); |
|
92 |
|
|
93 |
public Iterable<FeatureReference> queryReferences(Geometry geom); |
|
94 |
|
|
95 |
public Feature findFirst(Expression expression); |
|
96 |
|
|
97 |
public void restart(); |
|
98 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/CancelOperationException.java | ||
---|---|---|
1 |
package org.gvsig.topology.lib.api; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.exception.DataException; |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
* @author jjdelcerro |
|
8 |
*/ |
|
9 |
public class CancelOperationException extends DataException { |
|
10 |
|
|
11 |
public CancelOperationException(String msg) { |
|
12 |
super("_CancelOperationException", msg, 0); |
|
13 |
} |
|
14 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyPlan.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import java.util.Collection; |
|
27 |
import org.gvsig.fmap.dal.DataStore; |
|
28 |
import org.gvsig.json.SupportJson; |
|
29 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @author jjdelcerro |
|
34 |
*/ |
|
35 |
public interface TopologyPlan extends SupportJson, TopologyDataSetResolver { |
|
36 |
|
|
37 |
|
|
38 |
public String getName(); |
|
39 |
|
|
40 |
public void setName(String name); |
|
41 |
|
|
42 |
public double getTolerance(); |
|
43 |
|
|
44 |
public void setTolerance(double tolerance); |
|
45 |
|
|
46 |
public void clear(); |
|
47 |
|
|
48 |
public void setTopologyServices(TopologyServices services); |
|
49 |
|
|
50 |
public TopologyServices getTopologyServices(); |
|
51 |
|
|
52 |
public SimpleTaskStatus getTaskStatus(); |
|
53 |
|
|
54 |
public void execute(); |
|
55 |
|
|
56 |
public TopologyDataSet addDataSet(String name, DataStore store); |
|
57 |
|
|
58 |
public TopologyDataSet addDataSet(TopologyDataSet dataSet); |
|
59 |
|
|
60 |
public void removeDataSet(TopologyDataSet dataSet); |
|
61 |
|
|
62 |
public boolean containsDataSet(String name); |
|
63 |
|
|
64 |
@Override |
|
65 |
public TopologyDataSet getDataSet(String name); |
|
66 |
|
|
67 |
public Collection<TopologyDataSet> getDataSets(); |
|
68 |
|
|
69 |
public Collection<TopologyDataSet> getSecondaryDataSets(TopologyRuleFactory ruleFactory); |
|
70 |
|
|
71 |
public TopologyRule addRule(String id, String dataSet1, String dataSet2, double tolerance); |
|
72 |
|
|
73 |
public TopologyRule addRule(TopologyRule rule); |
|
74 |
|
|
75 |
public void removeRule(TopologyRule rule); |
|
76 |
|
|
77 |
public Collection<TopologyRule> getRules(); |
|
78 |
|
|
79 |
public boolean hasRules(); |
|
80 |
|
|
81 |
public TopologyReport getReport(); |
|
82 |
|
|
83 |
public boolean canUseUI(); |
|
84 |
|
|
85 |
public void setUseUI(boolean useUI); |
|
86 |
|
|
87 |
public int getLastStatus(); |
|
88 |
|
|
89 |
public boolean getAcceptExceptions(); |
|
90 |
|
|
91 |
public void setAcceptExceptions(boolean acceptExceptions); |
|
92 |
|
|
93 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyReportLineSet.java | ||
---|---|---|
1 |
package org.gvsig.topology.lib.api; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import org.gvsig.tools.swing.api.ChangeListenerSupport; |
|
5 |
|
|
6 |
/** |
|
7 |
* |
|
8 |
* @author jjdelcerro |
|
9 |
*/ |
|
10 |
public interface TopologyReportLineSet extends ChangeListenerSupport { |
|
11 |
|
|
12 |
public List<TopologyReportLine> getLines(); |
|
13 |
|
|
14 |
public boolean isComplete(); |
|
15 |
|
|
16 |
public int size(); |
|
17 |
|
|
18 |
public TopologyReportLine get(int index); |
|
19 |
|
|
20 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRuleFactory.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import java.util.List; |
|
27 |
import org.gvsig.tools.dynobject.DynObject; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author jjdelcerro |
|
32 |
*/ |
|
33 |
public interface TopologyRuleFactory { |
|
34 |
|
|
35 |
public String getId(); |
|
36 |
|
|
37 |
public String getName(); |
|
38 |
|
|
39 |
public String getDescription(); |
|
40 |
|
|
41 |
public List<Integer> getGeometryTypeDataSet1(); |
|
42 |
|
|
43 |
public List<Integer> getGeometryTypeDataSet2(); |
|
44 |
|
|
45 |
public DynObject createRuleParameters(); |
|
46 |
|
|
47 |
public TopologyRule createRule(String dataSet1, String dataSet2, double tolerance); |
|
48 |
|
|
49 |
public boolean hasRuleParameters(); |
|
50 |
|
|
51 |
public boolean hasSecondaryDataSet(); |
|
52 |
|
|
53 |
public boolean canApplyToDataSet(TopologyDataSet dataSet); |
|
54 |
|
|
55 |
public boolean canApplyToSecondaryDataSet(TopologyDataSet dataSet); |
|
56 |
|
|
57 |
|
|
58 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyLocator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.locator.AbstractLocator; |
|
27 |
import org.gvsig.tools.locator.Locator; |
|
28 |
import org.gvsig.tools.locator.LocatorException; |
|
29 |
|
|
30 |
@SuppressWarnings("rawtypes") |
|
31 |
public class TopologyLocator extends AbstractLocator { |
|
32 |
|
|
33 |
private static final String LOCATOR_NAME = "TopologyLocator"; |
|
34 |
|
|
35 |
public static final String TOPOLOGY_MANAGER_NAME = |
|
36 |
"org.gvsig.topology.manager"; |
|
37 |
|
|
38 |
private static final String TOPOLOGY_MANAGER_DESCRIPTION = |
|
39 |
"Topology Manager of gvSIG"; |
|
40 |
|
|
41 |
private static final TopologyLocator instance = new TopologyLocator(); |
|
42 |
|
|
43 |
private TopologyLocator() { |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Return the singleton instance. |
|
49 |
* |
|
50 |
* @return the singleton instance |
|
51 |
*/ |
|
52 |
public static TopologyLocator getInstance() { |
|
53 |
return instance; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public String getLocatorName() { |
|
58 |
return LOCATOR_NAME; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Return a reference to TopologyManager. |
|
63 |
* |
|
64 |
* @return a reference to TopologyManager |
|
65 |
* @throws LocatorException |
|
66 |
* if there is no access to the class or the class cannot be |
|
67 |
* instantiated |
|
68 |
* @see Locator#get(String) |
|
69 |
*/ |
|
70 |
public static TopologyManager getTopologyManager() |
|
71 |
throws LocatorException { |
|
72 |
return (TopologyManager) getInstance().get(TOPOLOGY_MANAGER_NAME); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Registers the Class implementing the TopologyManager interface. |
|
77 |
* |
|
78 |
* @param clazz |
|
79 |
* implementing the TopologyManager interface |
|
80 |
*/ |
|
81 |
public static void registerTopologyManager(Class clazz) { |
|
82 |
getInstance().register(TOPOLOGY_MANAGER_NAME, |
|
83 |
TOPOLOGY_MANAGER_DESCRIPTION, clazz); |
|
84 |
} |
|
85 |
|
|
86 |
public static void registerDefaultTopologyManager(Class clazz) { |
|
87 |
getInstance().registerDefault(TOPOLOGY_MANAGER_NAME, |
|
88 |
TOPOLOGY_MANAGER_DESCRIPTION, clazz); |
|
89 |
} |
|
90 |
|
|
91 |
|
|
92 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.DALLibrary; |
|
27 |
import org.gvsig.fmap.geom.GeometryLibrary; |
|
28 |
import org.gvsig.tools.ToolsLibrary; |
|
29 |
import org.gvsig.tools.library.AbstractLibrary; |
|
30 |
import org.gvsig.tools.library.LibraryException; |
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* @author jjdelcerro |
|
35 |
*/ |
|
36 |
public class TopologyLibrary extends AbstractLibrary { |
|
37 |
|
|
38 |
@Override |
|
39 |
public void doRegistration() { |
|
40 |
super.doRegistration(); |
|
41 |
registerAsAPI(TopologyLibrary.class); |
|
42 |
this.require(ToolsLibrary.class); |
|
43 |
this.require(DALLibrary.class); |
|
44 |
this.require(GeometryLibrary.class); |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
protected void doInitialize() throws LibraryException { |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
protected void doPostInitialize() throws LibraryException { |
|
53 |
} |
|
54 |
|
|
55 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRuleAction.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.dynobject.DynObject; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @author jjdelcerro |
|
31 |
*/ |
|
32 |
public interface TopologyRuleAction { |
|
33 |
|
|
34 |
public static final int EXECUTE_OK = 0; |
|
35 |
public static final int EXECUTE_FAIL = 1; |
|
36 |
|
|
37 |
public String getId(); |
|
38 |
|
|
39 |
public String getName(); |
|
40 |
|
|
41 |
public String getShortDescription(); |
|
42 |
|
|
43 |
public TopologyRuleFactory getRuleFactory(); |
|
44 |
|
|
45 |
public boolean hasParameters(); |
|
46 |
|
|
47 |
public DynObject createParameters(); |
|
48 |
|
|
49 |
public int execute( |
|
50 |
TopologyRule rule, |
|
51 |
TopologyReportLine line, |
|
52 |
DynObject parameters |
|
53 |
) throws ExecuteTopologyRuleActionException; |
|
54 |
|
|
55 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/ExecuteTopologyRuleActionException.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
|
|
27 |
public class ExecuteTopologyRuleActionException extends RuntimeException { |
|
28 |
|
|
29 |
public ExecuteTopologyRuleActionException(Exception ex) { |
|
30 |
this.initCause(ex); |
|
31 |
} |
|
32 |
|
|
33 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyDataSetResolver.java | ||
---|---|---|
1 |
package org.gvsig.topology.lib.api; |
|
2 |
|
|
3 |
/** |
|
4 |
* |
|
5 |
* @author gvSIG Team |
|
6 |
*/ |
|
7 |
public interface TopologyDataSetResolver { |
|
8 |
public TopologyDataSet getDataSet(String name); |
|
9 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyRule.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import java.util.List; |
|
27 |
import org.gvsig.json.SupportJson; |
|
28 |
import org.gvsig.tools.dynobject.DynObject; |
|
29 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @author gvSIG Team |
|
34 |
*/ |
|
35 |
public interface TopologyRule extends SupportJson, org.gvsig.tools.lang.Cloneable { |
|
36 |
|
|
37 |
public void execute(SimpleTaskStatus taskStatus, TopologyReport report) throws ExecuteTopologyRuleException; |
|
38 |
|
|
39 |
public String getName(); |
|
40 |
|
|
41 |
public String getId(); |
|
42 |
|
|
43 |
public TopologyPlan getPlan(); |
|
44 |
|
|
45 |
public TopologyRuleFactory getFactory(); |
|
46 |
|
|
47 |
public TopologyDataSet getDataSet1(); |
|
48 |
|
|
49 |
public TopologyDataSet getDataSet2(); |
|
50 |
|
|
51 |
public double getTolerance(); |
|
52 |
|
|
53 |
public List<TopologyRuleAction> getActions(); |
|
54 |
|
|
55 |
public TopologyRuleAction getAction(String name); |
|
56 |
|
|
57 |
public long getSteps(); |
|
58 |
|
|
59 |
public void setParameters(DynObject parameters); |
|
60 |
|
|
61 |
public DynObject getParameters(); |
|
62 |
|
|
63 |
@Override |
|
64 |
public TopologyRule clone() throws CloneNotSupportedException; |
|
65 |
|
|
66 |
public void setDataSetResolver(TopologyDataSetResolver resolver); |
|
67 |
|
|
68 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/ExecuteTopologyRuleException.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.topology.lib.api; |
|
7 |
|
|
8 |
/** |
|
9 |
* |
|
10 |
* @author jjdelcerro |
|
11 |
*/ |
|
12 |
public class ExecuteTopologyRuleException extends RuntimeException { |
|
13 |
public ExecuteTopologyRuleException(Exception ex) { |
|
14 |
this.initCause(ex); |
|
15 |
} |
|
16 |
|
|
17 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import java.util.List; |
|
27 |
import org.gvsig.fmap.dal.DataStore; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author jjdelcerro |
|
32 |
*/ |
|
33 |
public interface TopologyManager { |
|
34 |
|
|
35 |
public static final String RULE_GEOMETRYISVALID_ID = "GeometryIsValid"; |
|
36 |
public static final String RULE_GEOMETRYMUSTNOTBENULL_ID = "GeometryMustNotBeNull"; |
|
37 |
|
|
38 |
public static int TOPOLOGY_PLAN_STATUS_NOT_EXECUTED = -1; |
|
39 |
public static int TOPOLOGY_PLAN_STATUS_PASSED = 0; |
|
40 |
public static int TOPOLOGY_PLAN_STATUS_NOT_PASSED = 1; |
|
41 |
|
|
42 |
public TopologyPlan createTopologyPlan(); |
|
43 |
|
|
44 |
public List<TopologyRuleFactory> getRuleFactories(); |
|
45 |
|
|
46 |
public TopologyRuleFactory getRulefactory(String id); |
|
47 |
|
|
48 |
public List<TopologyRuleFactory> getRuleFactories(TopologyDataSet dataSet); |
|
49 |
|
|
50 |
public void addRuleFactories(TopologyRuleFactory factory); |
|
51 |
|
|
52 |
public TopologyDataSet createDataSet(String name, DataStore store); |
|
53 |
|
|
54 |
public void setDefaultServices(TopologyServices services); |
|
55 |
|
|
56 |
public TopologyServices getDefaultServices(); |
|
57 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/TopologyReport.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.api; |
|
25 |
|
|
26 |
import java.util.List; |
|
27 |
import org.gvsig.fmap.dal.feature.Feature; |
|
28 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
29 |
import org.gvsig.fmap.geom.Geometry; |
|
30 |
|
|
31 |
/** |
|
32 |
* |
|
33 |
* @author jjdelcerro |
|
34 |
*/ |
|
35 |
public interface TopologyReport extends TopologyReportLineSet { |
|
36 |
|
|
37 |
public static String RULE_ID = "RULE_ID"; |
|
38 |
public static String IS_ERROR = "IS_ERROR"; |
|
39 |
public static String IS_EXCEPTION = "IS_EXCEPTION"; |
|
40 |
public static String GEOMETRY = "GEOMETRY"; |
|
41 |
|
|
42 |
|
|
43 |
public TopologyReportLine addLine( |
|
44 |
TopologyRule rule, |
|
45 |
TopologyDataSet dataSet1, |
|
46 |
TopologyDataSet dataSet2, |
|
47 |
Geometry geometry, |
|
48 |
Geometry error, |
|
49 |
FeatureReference feature1, |
|
50 |
FeatureReference feature2, |
|
51 |
boolean exception, |
|
52 |
String description |
|
53 |
); |
|
54 |
|
|
55 |
public TopologyReportLine addLine( |
|
56 |
TopologyRule rule, |
|
57 |
TopologyDataSet dataSet1, |
|
58 |
TopologyDataSet dataSet2, |
|
59 |
Geometry geometry, |
|
60 |
Geometry error, |
|
61 |
FeatureReference feature1, |
|
62 |
FeatureReference feature2, |
|
63 |
int primitive1, |
|
64 |
int primitive2, |
|
65 |
boolean exception, |
|
66 |
String description, |
|
67 |
String data |
|
68 |
); |
|
69 |
|
|
70 |
public void removeAllLines(); |
|
71 |
|
|
72 |
@Override |
|
73 |
public List<TopologyReportLine> getLines(); |
|
74 |
|
|
75 |
public List<TopologyReportLine> getLines(String filter); |
|
76 |
|
|
77 |
public TopologyReportLineSet getLineSet(String filter); |
|
78 |
|
|
79 |
public int getStatus(); |
|
80 |
|
|
81 |
public TopologyReportLine addCodeException( |
|
82 |
TopologyRule rule, |
|
83 |
TopologyDataSet dataSet1, |
|
84 |
Feature feature1, |
|
85 |
Throwable exception |
|
86 |
); |
|
87 |
|
|
88 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/api/PerformOperationException.java | ||
---|---|---|
1 |
package org.gvsig.topology.lib.api; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.exception.DataException; |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
* @author jjdelcerro |
|
8 |
*/ |
|
9 |
public class PerformOperationException extends DataException { |
|
10 |
|
|
11 |
public PerformOperationException(String msg) { |
|
12 |
super("_CancelOperationException", msg, 0); |
|
13 |
} |
|
14 |
|
|
15 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRuleFactory.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.spi; |
|
25 |
|
|
26 |
import java.net.URL; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Objects; |
|
29 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
30 |
import org.gvsig.fmap.geom.GeometryManager; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.dynobject.DynClass; |
|
33 |
import org.gvsig.tools.dynobject.DynObject; |
|
34 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
35 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
36 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
37 |
import org.json.JSONObject; |
|
38 |
import org.slf4j.Logger; |
|
39 |
import org.slf4j.LoggerFactory; |
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
* @author jjdelcerro |
|
44 |
*/ |
|
45 |
public abstract class AbstractTopologyRuleFactory implements TopologyRuleFactory { |
|
46 |
|
|
47 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractTopologyRuleFactory.class); |
|
48 |
|
|
49 |
private final String id; |
|
50 |
protected String name; |
|
51 |
protected String description; |
|
52 |
private final List<Integer> geometryTypeDataSet1; |
|
53 |
private final List<Integer> geometryTypeDataSet2; |
|
54 |
|
|
55 |
protected AbstractTopologyRuleFactory( |
|
56 |
String id, |
|
57 |
String name, |
|
58 |
String description, |
|
59 |
List<Integer> geometryTypeDataSet1, |
|
60 |
List<Integer> geometryTypeDataSet2 |
|
61 |
) { |
|
62 |
this.id = id; |
|
63 |
this.name = name; |
|
64 |
this.description = description; |
|
65 |
this.geometryTypeDataSet1 = geometryTypeDataSet1; |
|
66 |
this.geometryTypeDataSet2 = geometryTypeDataSet2; |
|
67 |
this.load_from_resource(); |
|
68 |
} |
|
69 |
|
|
70 |
protected AbstractTopologyRuleFactory( |
|
71 |
String id, |
|
72 |
String name, |
|
73 |
String description, |
|
74 |
List<Integer> geometryTypeDataSet1 |
|
75 |
) { |
|
76 |
this(id, name, description, geometryTypeDataSet1, null); |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public String toString() { |
|
81 |
return this.getName(); |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public String getId() { |
|
86 |
return this.id; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public String getName() { |
|
91 |
return this.name; |
|
92 |
} |
|
93 |
|
|
94 |
@Override |
|
95 |
public String getDescription() { |
|
96 |
return this.description; |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public List<Integer> getGeometryTypeDataSet1() { |
|
101 |
return this.geometryTypeDataSet1; |
|
102 |
} |
|
103 |
|
|
104 |
@Override |
|
105 |
public List<Integer> getGeometryTypeDataSet2() { |
|
106 |
return this.geometryTypeDataSet2; |
|
107 |
} |
|
108 |
|
|
109 |
@Override |
|
110 |
public boolean hasSecondaryDataSet() { |
|
111 |
return this.geometryTypeDataSet2 != null && !this.geometryTypeDataSet2.isEmpty(); |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
|
115 |
public boolean canApplyToDataSet(TopologyDataSet dataSet) { |
|
116 |
if (geometryTypeDataSet1== null) { |
|
117 |
return true; |
|
118 |
} |
|
119 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
120 |
for (Integer geometryType : geometryTypeDataSet1) { |
|
121 |
boolean canApply = geomManager.isSubtype(geometryType, dataSet.getGeometryType()); |
|
122 |
if( canApply ) { |
|
123 |
return true; |
|
124 |
} |
|
125 |
} |
|
126 |
return false; |
|
127 |
} |
|
128 |
|
|
129 |
@Override |
|
130 |
public boolean canApplyToSecondaryDataSet(TopologyDataSet dataSet) { |
|
131 |
if( !this.hasSecondaryDataSet() ) { |
|
132 |
return false; |
|
133 |
} |
|
134 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
135 |
for (Integer geometryType : geometryTypeDataSet2) { |
|
136 |
boolean canApply = geomManager.isSubtype(geometryType, dataSet.getGeometryType() ); |
|
137 |
if( canApply ) { |
|
138 |
return true; |
|
139 |
} |
|
140 |
} |
|
141 |
return false; |
|
142 |
} |
|
143 |
|
|
144 |
private void load_from_resource() { |
|
145 |
URL url = RuleResourceLoaderUtils.getRuleURL(this.id); |
|
146 |
JSONObject json = RuleResourceLoaderUtils.getRule(url); |
|
147 |
load_from_resource(url, json); |
|
148 |
} |
|
149 |
|
|
150 |
protected void load_from_resource(URL jsonUrl, JSONObject json) { |
|
151 |
if( json == null ) { |
|
152 |
return; |
|
153 |
} |
|
154 |
if( json.has("name") ) { |
|
155 |
this.name = json.getString("name"); |
|
156 |
} |
|
157 |
if( json.has("description") ) { |
|
158 |
this.description = RuleResourceLoaderUtils.getDescription(jsonUrl, json); |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
@Override |
|
163 |
public DynObject createRuleParameters() { |
|
164 |
return null; |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
public boolean hasRuleParameters() { |
|
169 |
return false; |
|
170 |
} |
|
171 |
|
|
172 |
@Override |
|
173 |
public int hashCode() { |
|
174 |
int hash = 7; |
|
175 |
hash = 71 * hash + Objects.hashCode(this.name); |
|
176 |
return hash; |
|
177 |
} |
|
178 |
|
|
179 |
@Override |
|
180 |
public boolean equals(Object obj) { |
|
181 |
if (this == obj) { |
|
182 |
return true; |
|
183 |
} |
|
184 |
if (obj == null) { |
|
185 |
return false; |
|
186 |
} |
|
187 |
if (getClass() != obj.getClass()) { |
|
188 |
return false; |
|
189 |
} |
|
190 |
final AbstractTopologyRuleFactory other = (AbstractTopologyRuleFactory) obj; |
|
191 |
if (!Objects.equals(this.name, other.name)) { |
|
192 |
return false; |
|
193 |
} |
|
194 |
return true; |
|
195 |
} |
|
196 |
|
|
197 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRuleAction.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.spi; |
|
25 |
|
|
26 |
import java.net.URL; |
|
27 |
import org.gvsig.tools.dynobject.DynObject; |
|
28 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
29 |
import org.gvsig.topology.lib.api.TopologyRuleAction; |
|
30 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
31 |
import org.json.JSONObject; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
* @author jjdelcerro |
|
36 |
*/ |
|
37 |
public abstract class AbstractTopologyRuleAction implements TopologyRuleAction { |
|
38 |
|
|
39 |
protected String idRule; |
|
40 |
protected String idAction; |
|
41 |
protected String name; |
|
42 |
protected String shortDescription; |
|
43 |
|
|
44 |
protected AbstractTopologyRuleAction( |
|
45 |
String idRule |
|
46 |
) { |
|
47 |
this.idRule = idRule; |
|
48 |
this.idAction = null; |
|
49 |
this.name = null; |
|
50 |
this.shortDescription = null; |
|
51 |
} |
|
52 |
|
|
53 |
protected AbstractTopologyRuleAction( |
|
54 |
String idRule, |
|
55 |
String idAction, |
|
56 |
String name, |
|
57 |
String shortDescription |
|
58 |
) { |
|
59 |
this.idRule = idRule; |
|
60 |
this.idAction = idAction; |
|
61 |
this.name = name; |
|
62 |
this.shortDescription = shortDescription; |
|
63 |
this.load_from_resource(); |
|
64 |
} |
|
65 |
|
|
66 |
@Override |
|
67 |
public String getId() { |
|
68 |
return this.idAction; |
|
69 |
} |
|
70 |
|
|
71 |
@Override |
|
72 |
public String getName() { |
|
73 |
return this.name; |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public String getShortDescription() { |
|
78 |
return this.shortDescription; |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public TopologyRuleFactory getRuleFactory() { |
|
83 |
TopologyRuleFactory f = TopologyLocator.getTopologyManager().getRulefactory(this.idRule); |
|
84 |
return f; |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
public boolean hasParameters() { |
|
89 |
return false; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public DynObject createParameters() { |
|
94 |
return null; |
|
95 |
} |
|
96 |
|
|
97 |
private void load_from_resource() { |
|
98 |
URL url = RuleResourceLoaderUtils.getRuleURL(this.idRule); |
|
99 |
JSONObject rule = RuleResourceLoaderUtils.getRule(url); |
|
100 |
load_from_resource(url, rule); |
|
101 |
} |
|
102 |
|
|
103 |
protected void load_from_resource(URL jsonUrl, JSONObject rule) { |
|
104 |
if( rule == null ) { |
|
105 |
return; |
|
106 |
} |
|
107 |
JSONObject action = RuleResourceLoaderUtils.getAction(rule, this.idAction); |
|
108 |
if( action.has("name") ) { |
|
109 |
this.name = action.getString("name"); |
|
110 |
} |
|
111 |
if( action.has("description") ) { |
|
112 |
this.shortDescription = RuleResourceLoaderUtils.getDescription(jsonUrl, action); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/RuleResourceLoaderUtils.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.topology.lib.spi; |
|
7 |
|
|
8 |
import java.io.File; |
|
9 |
import java.io.InputStream; |
|
10 |
import java.net.MalformedURLException; |
|
11 |
import java.net.URL; |
|
12 |
import java.nio.charset.StandardCharsets; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Locale; |
|
15 |
import org.apache.commons.io.Charsets; |
|
16 |
import org.apache.commons.io.FilenameUtils; |
|
17 |
import org.apache.commons.io.IOUtils; |
|
18 |
import org.apache.commons.lang3.StringUtils; |
|
19 |
import org.json.JSONArray; |
|
20 |
import org.json.JSONObject; |
|
21 |
import org.slf4j.Logger; |
|
22 |
import org.slf4j.LoggerFactory; |
|
23 |
|
|
24 |
/** |
|
25 |
* |
|
26 |
* @author jjdelcerro |
|
27 |
*/ |
|
28 |
@SuppressWarnings("UseSpecificCatch") |
|
29 |
public class RuleResourceLoaderUtils { |
|
30 |
|
|
31 |
private static Logger LOGGER = LoggerFactory.getLogger(RuleResourceLoaderUtils.class); |
|
32 |
|
|
33 |
public static URL getRuleURL(String idRule) { |
|
34 |
String lang = Locale.getDefault().getLanguage(); |
|
35 |
URL url = RuleResourceLoaderUtils.class.getResource("/org/gvsig/topology/rules/"+lang+"/"+idRule+".json"); |
|
36 |
if( url == null ) { |
|
37 |
url = RuleResourceLoaderUtils.class.getResource("/org/gvsig/topology/rules/en/"+idRule+".json"); |
|
38 |
if( url == null ) { |
|
39 |
return null; |
|
40 |
} |
|
41 |
} |
|
42 |
return url; |
|
43 |
} |
|
44 |
|
|
45 |
public static JSONObject getRule(URL url) { |
|
46 |
if( url == null ) { |
|
47 |
return null; |
|
48 |
} |
|
49 |
InputStream is = null; |
|
50 |
JSONObject json; |
|
51 |
try { |
|
52 |
is = url.openStream(); |
|
53 |
List<String> lines = IOUtils.readLines(is, StandardCharsets.UTF_8); |
|
54 |
json = new JSONObject(StringUtils.join(lines, "\n")); |
|
55 |
} catch (Exception ex) { |
|
56 |
LOGGER.warn("Can't load resource from json file '"+url.toString()+"'.", ex); |
|
57 |
return null; |
|
58 |
} finally { |
|
59 |
IOUtils.closeQuietly(is); |
|
60 |
} |
|
61 |
return json; |
|
62 |
} |
|
63 |
|
|
64 |
public static JSONObject getRule(String idRuleOrPathname) { |
|
65 |
if( idRuleOrPathname==null ) { |
|
66 |
return null; |
|
67 |
} |
|
68 |
if( idRuleOrPathname.endsWith(".json") ) { |
|
69 |
// Asumimos que es una ruta al fichero json. |
|
70 |
return getRule(new File(idRuleOrPathname)); |
|
71 |
} |
|
72 |
// Asumimos que es un ID de regla |
|
73 |
URL url = getRuleURL(idRuleOrPathname); |
|
74 |
if( url == null ) { |
|
75 |
return null; |
|
76 |
} |
|
77 |
return getRule(url); |
|
78 |
} |
|
79 |
|
|
80 |
public static JSONObject getRule(File jsonfile) { |
|
81 |
if( jsonfile == null || !jsonfile.exists() ) { |
|
82 |
return null; |
|
83 |
} |
|
84 |
try { |
|
85 |
return getRule(jsonfile.toURI().toURL()); |
|
86 |
} catch (MalformedURLException ex) { |
|
87 |
LOGGER.warn("Can't load resource from json file '"+jsonfile.toString()+"'.", ex); |
|
88 |
return null; |
|
89 |
} |
|
90 |
} |
|
91 |
|
|
92 |
public static String getDescription(URL jsonUrl, JSONObject json) { |
|
93 |
String description = null; |
|
94 |
|
|
95 |
if( json.has("description") ) { |
|
96 |
Object x = json.get("description"); |
|
97 |
if( x instanceof String ) { |
|
98 |
description = (String) x; |
|
99 |
} else if( x instanceof JSONArray ) { |
|
100 |
StringBuilder builder = new StringBuilder(); |
|
101 |
for (int i = 0; i < ((JSONArray)x).length(); i++) { |
|
102 |
if( i>0 ) { |
|
103 |
builder.append(" "); |
|
104 |
} |
|
105 |
builder.append(((JSONArray)x).getString(i)); |
|
106 |
} |
|
107 |
description = builder.toString(); |
|
108 |
} else { |
|
109 |
description = x.toString(); |
|
110 |
} |
|
111 |
if( description.contains("@@@") ) { |
|
112 |
description = StringUtils.replace( |
|
113 |
description, |
|
114 |
"@@@", |
|
115 |
FilenameUtils.removeExtension(jsonUrl.toString()) |
|
116 |
); |
|
117 |
} |
|
118 |
} |
|
119 |
return description; |
|
120 |
} |
|
121 |
|
|
122 |
public static JSONObject getAction(JSONObject rule, String idAction) { |
|
123 |
if( !rule.has("actions") ) { |
|
124 |
return null; |
|
125 |
} |
|
126 |
if( !rule.getJSONObject("actions").has(idAction) ) { |
|
127 |
return null; |
|
128 |
} |
|
129 |
JSONObject action = rule.getJSONObject("actions").getJSONObject(idAction); |
|
130 |
return action; |
|
131 |
} |
|
132 |
|
|
133 |
} |
org.gvsig.topology/tags/org.gvsig.topology-1.0.168/org.gvsig.topology.lib/org.gvsig.topology.lib.api/src/main/java/org/gvsig/topology/lib/spi/AbstractTopologyRule.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 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.topology.lib.spi; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.Collections; |
|
28 |
import java.util.List; |
|
29 |
import java.util.Objects; |
|
30 |
import javax.json.JsonObject; |
|
31 |
import org.apache.commons.lang3.StringUtils; |
|
32 |
import org.gvsig.fmap.dal.exception.DataException; |
|
33 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
34 |
import org.gvsig.fmap.dal.feature.Feature; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
36 |
import org.gvsig.fmap.geom.Geometry; |
|
37 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
38 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
39 |
import org.gvsig.json.Json; |
|
40 |
import org.gvsig.json.JsonObjectBuilder; |
|
41 |
import org.gvsig.tools.dynobject.DynClass; |
|
42 |
import org.gvsig.tools.dynobject.DynField; |
|
43 |
import org.gvsig.tools.dynobject.DynObject; |
|
44 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
45 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
46 |
import org.gvsig.topology.lib.api.TopologyDataSet; |
|
47 |
import org.gvsig.topology.lib.api.TopologyDataSetResolver; |
|
48 |
import org.gvsig.topology.lib.api.TopologyLocator; |
|
49 |
import org.gvsig.topology.lib.api.TopologyManager; |
|
50 |
import org.gvsig.topology.lib.api.TopologyPlan; |
|
51 |
import org.gvsig.topology.lib.api.TopologyReport; |
|
52 |
import org.gvsig.topology.lib.api.TopologyRule; |
|
53 |
import org.gvsig.topology.lib.api.TopologyRuleAction; |
|
54 |
import org.gvsig.topology.lib.api.TopologyRuleFactory; |
|
55 |
import org.slf4j.Logger; |
|
56 |
import org.slf4j.LoggerFactory; |
|
57 |
|
|
58 |
/** |
|
59 |
* |
|
60 |
* @author jjdelcerro |
|
61 |
*/ |
|
62 |
public abstract class AbstractTopologyRule implements TopologyRule { |
|
63 |
|
|
64 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractTopologyRule.class); |
|
65 |
|
|
66 |
private TopologyPlan plan; |
|
67 |
private TopologyDataSetResolver datasetResolver; |
Also available in: Unified diff