Revision 20099
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/build.xml | ||
---|---|---|
1 | 1 |
<project name="Generar extension en Andami" default="generate-without-source" basedir="."> |
2 |
<description>
|
|
2 |
<description>
|
|
3 | 3 |
Instala el plugin de ejemplo en Andami. |
4 | 4 |
</description> |
5 |
<!-- set global properties for this build -->
|
|
6 |
<property name="src" location="src"/>
|
|
7 |
<property name="build" location="bin"/>
|
|
8 |
<property name="dist" location="dist"/>
|
|
9 |
<property name="dist-src-name" value="dist-src"/>
|
|
10 |
<property name="dist-src" location="${dist-src-name}"/>
|
|
11 |
<property name="plugin" value="com.iver.cit.gvsig.graph"/>
|
|
12 |
<property name="plugin-fmap-gvsig" value="com.iver.cit.gvsig.graph-fmap-gvsig"/>
|
|
13 |
<property name="plugin-graph-gvsig" value="com.iver.cit.gvsig.graph-gvsig"/>
|
|
14 |
<property name="extension-dir" location="../_fwAndami/gvSIG/extensiones"/>
|
|
15 |
<property name="mainPlugin" value="com.iver.cit.gvsig" />
|
|
16 |
<property name="fmapLibs" location="../libFMap/lib"/>
|
|
17 |
<target name="init">
|
|
18 |
<!-- Create the time stamp -->
|
|
19 |
<tstamp/>
|
|
20 |
<!-- Create the build directory structure used by compile -->
|
|
21 |
<mkdir dir="${build}"/>
|
|
22 |
<mkdir dir="${dist}"/>
|
|
5 |
<!-- set global properties for this build -->
|
|
6 |
<property name="src" location="src" />
|
|
7 |
<property name="build" location="bin" />
|
|
8 |
<property name="dist" location="dist" />
|
|
9 |
<property name="dist-src-name" value="dist-src" />
|
|
10 |
<property name="dist-src" location="${dist-src-name}" />
|
|
11 |
<property name="plugin" value="com.iver.cit.gvsig.graph" />
|
|
12 |
<property name="plugin-fmap-gvsig" value="com.iver.cit.gvsig.graph-fmap-gvsig" />
|
|
13 |
<property name="plugin-graph-gvsig" value="com.iver.cit.gvsig.graph-gvsig" />
|
|
14 |
<property name="extension-dir" location="../_fwAndami/gvSIG/extensiones" />
|
|
15 |
<property name="mainPlugin" value="com.iver.cit.gvsig" />
|
|
16 |
<property name="fmapLibs" location="../libFMap/lib" />
|
|
17 |
<target name="init">
|
|
18 |
<!-- Create the time stamp -->
|
|
19 |
<tstamp />
|
|
20 |
<!-- Create the build directory structure used by compile -->
|
|
21 |
<mkdir dir="${build}" />
|
|
22 |
<mkdir dir="${dist}" />
|
|
23 | 23 |
|
24 |
</target>
|
|
24 |
</target>
|
|
25 | 25 |
|
26 |
<target name="generate-source-package"> |
|
27 |
<delete dir="${dist-src}" quiet="yes"/> |
|
28 |
<mkdir dir="${dist-src}"/> |
|
29 |
<basename file="${basedir}" property="extensionProjectDir"/> |
|
30 |
<mkdir dir="${dist-src}/${extensionProjectDir}"/> |
|
31 |
<copy todir="${dist-src}/${extensionProjectDir}"> |
|
32 |
<fileset dir="${basedir}"/> |
|
33 |
</copy> |
|
34 |
<copy todir="${dist-src}"> |
|
35 |
<fileset dir="${basedir}/install/resources" includes="Leeme-predes.txt, Readme-predes.txt"/> |
|
36 |
</copy> |
|
37 |
<delete dir="${dist-src}/${extensionProjectDir}/bin"/> |
|
38 |
<mkdir dir="${dist-src}/${extensionProjectDir}/bin"/> |
|
39 |
<delete dir="${dist-src}/${extensionProjectDir}/src-test"/> |
|
40 |
<mkdir dir="${dist-src}/${extensionProjectDir}/src-test"/> |
|
41 |
<delete dir="${dist-src}/${extensionProjectDir}/install"/> |
|
42 |
<delete dir="${dist-src}/${extensionProjectDir}/dist" quiet="yes"/> |
|
43 |
<delete dir="${dist-src}/${extensionProjectDir}/dist-src" quiet="yes"/> |
|
44 |
<delete dir="${dist-src}/${extensionProjectDir}/test-files" quiet="yes"/> |
|
45 |
<delete dir="${dist-src}/${extensionProjectDir}/test-file" quiet="yes"/> |
|
46 |
<loadproperties srcFile="build.number"/> |
|
47 |
<replace casesensitive="true" |
|
48 |
token="#build.number#" |
|
49 |
value="${build.number}" |
|
50 |
dir="${dist-src}" |
|
51 |
includes="Leeme-predes.txt, Readme-predes.txt"/> |
|
52 |
<zip destfile="${dist-src}/gvSIG_pilot_redes-10_${build.number}-src.zip" |
|
53 |
basedir="${dist-src-name}" |
|
54 |
excludes="*.zip,**/.svn" |
|
55 |
/> |
|
26 |
<target name="generate-source-package"> |
|
27 |
<delete dir="${dist-src}" quiet="yes" /> |
|
28 |
<mkdir dir="${dist-src}" /> |
|
29 |
<basename file="${basedir}" property="extensionProjectDir" /> |
|
30 |
<mkdir dir="${dist-src}/${extensionProjectDir}" /> |
|
31 |
<copy todir="${dist-src}/${extensionProjectDir}"> |
|
32 |
<fileset dir="${basedir}" /> |
|
33 |
</copy> |
|
34 |
<copy todir="${dist-src}"> |
|
35 |
<fileset dir="${basedir}/install/resources" includes="Leeme-predes.txt, Readme-predes.txt" /> |
|
36 |
</copy> |
|
37 |
<delete dir="${dist-src}/${extensionProjectDir}/bin" /> |
|
38 |
<mkdir dir="${dist-src}/${extensionProjectDir}/bin" /> |
|
39 |
<delete dir="${dist-src}/${extensionProjectDir}/src-test" /> |
|
40 |
<mkdir dir="${dist-src}/${extensionProjectDir}/src-test" /> |
|
41 |
<delete dir="${dist-src}/${extensionProjectDir}/install" /> |
|
42 |
<delete dir="${dist-src}/${extensionProjectDir}/dist" quiet="yes" /> |
|
43 |
<delete dir="${dist-src}/${extensionProjectDir}/dist-src" quiet="yes" /> |
|
44 |
<delete dir="${dist-src}/${extensionProjectDir}/test-files" quiet="yes" /> |
|
45 |
<delete dir="${dist-src}/${extensionProjectDir}/test-file" quiet="yes" /> |
|
46 |
<loadproperties srcFile="build.number" /> |
|
47 |
<replace casesensitive="true" token="#build.number#" value="${build.number}" dir="${dist-src}" includes="Leeme-predes.txt, Readme-predes.txt" /> |
|
48 |
<zip destfile="${dist-src}/gvSIG_pilot_redes-10_${build.number}-src.zip" basedir="${dist-src-name}" excludes="*.zip,**/.svn" /> |
|
56 | 49 |
|
57 |
</target>
|
|
50 |
</target>
|
|
58 | 51 |
|
59 |
<target name="buildNumber"> |
|
60 |
<propertyfile |
|
61 |
file="build.number" |
|
62 |
comment="Build Number for ANT. Do not edit!"> |
|
63 |
<entry key="build.number" default="0" type="int" operation="+"/> |
|
64 |
</propertyfile> |
|
65 |
<property file="build.number"/> |
|
66 |
</target> |
|
52 |
<target name="buildNumber"> |
|
53 |
<propertyfile file="build.number" comment="Build Number for ANT. Do not edit!"> |
|
54 |
<entry key="build.number" default="0" type="int" operation="+" /> |
|
55 |
</propertyfile> |
|
56 |
<property file="build.number" /> |
|
57 |
</target> |
|
67 | 58 |
|
68 |
<target name="distribution" |
|
69 |
description="increment build number and generate the distribution without the source file" |
|
70 |
depends="buildNumber,generate-without-source"> |
|
71 |
</target> |
|
59 |
<target name="distribution" description="increment build number and generate the distribution without the source file" depends="buildNumber,generate-without-source"> |
|
60 |
</target> |
|
72 | 61 |
|
73 |
<target name="generate-without-source" description="generate the distribution without the source file" > |
|
74 |
<!-- Create the distribution directory --> |
|
75 |
<mkdir dir="${dist}"/> |
|
76 |
<mkdir dir="${dist}/lib"/> |
|
77 | 62 |
|
63 |
<target name="generate independent library"> |
|
64 |
<jar jarfile="fmap-graph.jar" |
|
65 |
basedir="${build}" |
|
66 |
includes="com/iver/cit/gvsig/graph/core/** com/iver/cit/gvsig/graph/solvers/**" |
|
67 |
update="true" /> |
|
78 | 68 |
|
69 |
</target> |
|
70 |
<target name="generate-without-source" description="generate the distribution without the source file"> |
|
71 |
<!-- Create the distribution directory --> |
|
72 |
<mkdir dir="${dist}" /> |
|
73 |
<mkdir dir="${dist}/lib" /> |
|
79 | 74 |
|
80 |
<!-- |
|
75 |
|
|
76 |
|
|
77 |
<!-- |
|
81 | 78 |
- -> |
82 | 79 |
<jar jarfile="${fmapLibs}/jts-1.7.jar" basedir="${build}" update="yes" includes="com/vividsolutions/**"/> |
83 | 80 |
|
84 | 81 |
<!- - Put everything in ${build} into the MyProject-${DSTAMP}.jar file --> |
85 |
<jar jarfile="${dist}/lib/${plugin-fmap-gvsig}.jar" basedir="${build}" includes="com/iver/cit/fmap/**,com/iver/cit/gvsig/**,com/iver/cit/project/**" |
|
86 |
excludes="com/iver/cit/gvsig/project/documents/view/**" /> |
|
87 |
<jar jarfile="${dist}/lib/${plugin}.jar" basedir="${build}" includes="com/iver/cit/**"/> |
|
88 |
<jar jarfile="${extension-dir}/${mainPlugin}/lib/${plugin-graph-gvsig}.jar" |
|
89 |
basedir="${build}" |
|
90 |
includes="com/iver/cit/gvsig/project/documents/view/**" |
|
91 |
/> |
|
82 |
<jar jarfile="${dist}/lib/${plugin-fmap-gvsig}.jar" basedir="${build}" includes="com/iver/cit/fmap/**,com/iver/cit/gvsig/**,com/iver/cit/project/**" excludes="com/iver/cit/gvsig/project/documents/view/**" /> |
|
83 |
<jar jarfile="${dist}/lib/${plugin}.jar" basedir="${build}" includes="com/iver/cit/**" /> |
|
84 |
<jar jarfile="${extension-dir}/${mainPlugin}/lib/${plugin-graph-gvsig}.jar" basedir="${build}" includes="com/iver/cit/gvsig/project/documents/view/**" /> |
|
92 | 85 |
|
93 | 86 |
|
94 |
<copy file="config/config.xml" todir="${dist}"/> |
|
95 |
<copy file="config/about.htm" todir="${dist}"/> |
|
96 |
<loadproperties srcFile="build.number"/> |
|
97 |
<replace casesensitive="true" |
|
98 |
file="${dist}/about.htm" |
|
99 |
token="#build.number#" |
|
100 |
value="${build.number}"/> |
|
101 |
<copy file="build.number" todir="${dist}"/> |
|
102 |
<copy todir="${dist}"> |
|
103 |
<fileset dir="config/" includes="text*.properties"/> |
|
104 |
</copy> |
|
105 |
<copy todir="${dist}/lib"> |
|
106 |
<fileset dir="lib" includes="*"/> |
|
107 |
</copy> |
|
108 |
<copy todir="${dist}/images"> |
|
109 |
<fileset dir="images/" includes="*"/> |
|
110 |
</copy> |
|
111 |
<copy todir="${dist}/symbols"> |
|
112 |
<fileset dir="symbols/" includes="**/**"/> |
|
113 |
</copy> |
|
87 |
<copy file="config/config.xml" todir="${dist}" /> |
|
88 |
<copy file="config/about.htm" todir="${dist}" /> |
|
89 |
<loadproperties srcFile="build.number" /> |
|
90 |
<replace casesensitive="true" file="${dist}/about.htm" token="#build.number#" value="${build.number}" /> |
|
91 |
<copy file="build.number" todir="${dist}" /> |
|
92 |
<copy todir="${dist}"> |
|
93 |
<fileset dir="config/" includes="text*.properties" /> |
|
94 |
</copy> |
|
95 |
<copy todir="${dist}/lib"> |
|
96 |
<fileset dir="lib" includes="*" /> |
|
97 |
</copy> |
|
98 |
<copy todir="${dist}/images"> |
|
99 |
<fileset dir="images/" includes="*" /> |
|
100 |
</copy> |
|
101 |
<copy todir="${dist}/symbols"> |
|
102 |
<fileset dir="symbols/" includes="**/**" /> |
|
103 |
</copy> |
|
114 | 104 |
|
115 |
<copy todir="${extension-dir}/${plugin}/">
|
|
116 |
<!--<fileset dir="${dist}" includes="**/**"/>-->
|
|
117 |
<fileset dir="${dist}">
|
|
118 |
<exclude name="**/${plugin-fmap-gvsig}.jar"/>
|
|
119 |
<include name="**/**"/>
|
|
120 |
</fileset>
|
|
121 |
</copy>
|
|
122 |
<copy todir="${extension-dir}/${mainPlugin}/lib/">
|
|
123 |
<fileset dir="${dist}/lib" includes="**/${plugin-fmap-gvsig}.jar"/>
|
|
124 |
</copy>
|
|
125 |
<!--${extension-dir}/${mainPlugin}/lib/${mainPlugin}.jar <copy todir="${fmapLibs}">
|
|
105 |
<copy todir="${extension-dir}/${plugin}/">
|
|
106 |
<!--<fileset dir="${dist}" includes="**/**"/>-->
|
|
107 |
<fileset dir="${dist}">
|
|
108 |
<exclude name="**/${plugin-fmap-gvsig}.jar" />
|
|
109 |
<include name="**/**" />
|
|
110 |
</fileset>
|
|
111 |
</copy>
|
|
112 |
<copy todir="${extension-dir}/${mainPlugin}/lib/">
|
|
113 |
<fileset dir="${dist}/lib" includes="**/${plugin-fmap-gvsig}.jar" />
|
|
114 |
</copy>
|
|
115 |
<!--${extension-dir}/${mainPlugin}/lib/${mainPlugin}.jar <copy todir="${fmapLibs}">
|
|
126 | 116 |
<fileset dir="${dist}/lib" includes="**/${plugin-fmap-gvsig}.jar"/> |
127 | 117 |
</copy> --> |
128 |
<delete dir="${dist}"/>
|
|
129 |
</target>
|
|
118 |
<delete dir="${dist}" />
|
|
119 |
</target>
|
|
130 | 120 |
|
131 |
<target name="save-gvsig-jar-to-install-dir" description="Save the gvsig.jar to installdir" >
|
|
132 |
<!-- ******************************* -->
|
|
121 |
<target name="save-gvsig-jar-to-install-dir" description="Save the gvsig.jar to installdir">
|
|
122 |
<!-- ******************************* -->
|
|
133 | 123 |
|
134 |
<copy todir="./install">
|
|
135 |
<fileset dir="${extension-dir}/com.iver.cit.gvsig/lib/">
|
|
136 |
<include name="{plugin-graph-gvsig}.jar"/>
|
|
137 |
</fileset> |
|
138 |
</copy>
|
|
139 |
<!-- ******************************* -->
|
|
124 |
<copy todir="./install">
|
|
125 |
<fileset dir="${extension-dir}/com.iver.cit.gvsig/lib/">
|
|
126 |
<include name="{plugin-graph-gvsig}.jar" />
|
|
127 |
</fileset>
|
|
128 |
</copy>
|
|
129 |
<!-- ******************************* -->
|
|
140 | 130 |
|
141 |
</target>
|
|
131 |
</target>
|
|
142 | 132 |
</project> |
143 | 133 |
|
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src-test/com/iver/cit/gvsig/graphtests/TestLoader.java | ||
---|---|---|
23 | 23 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
24 | 24 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
25 | 25 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
26 |
import com.iver.cit.gvsig.graph.GraphException; |
|
27 | 26 |
import com.iver.cit.gvsig.graph.core.EdgeWeightLabeller; |
28 | 27 |
import com.iver.cit.gvsig.graph.core.FNode; |
28 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
29 | 29 |
import com.iver.cit.gvsig.graph.core.IGraph; |
30 | 30 |
import com.iver.cit.gvsig.graph.core.JungGraph; |
31 | 31 |
import com.iver.cit.gvsig.graph.core.Network; |
... | ... | |
120 | 120 |
* Test method for |
121 | 121 |
* 'com.iver.cit.gvsig.graph.core.NetworkLoader.loadNetwork()' |
122 | 122 |
*/ |
123 |
public void testLoadNetwork() { |
|
124 |
// if (true) return; |
|
125 |
NetworkLoader netLoader = new NetworkLoader(true); |
|
123 |
// public void testLoadNetwork() { |
|
124 |
// // if (true) return; |
|
125 |
// NetworkLoader netLoader = new NetworkLoader(true); |
|
126 |
// |
|
127 |
// DataSource dsNodes; |
|
128 |
// try { |
|
129 |
// dsNodes = dsf.createRandomDataSource("nodes", |
|
130 |
// DataSourceFactory.MANUAL_OPENING); |
|
131 |
// |
|
132 |
// DataSource dsEdges = dsf.createRandomDataSource("edges", |
|
133 |
// DataSourceFactory.MANUAL_OPENING); |
|
134 |
// |
|
135 |
// SelectableDataSource sdsNodes = new SelectableDataSource(dsNodes); |
|
136 |
// SelectableDataSource sdsEdges = new SelectableDataSource(dsEdges); |
|
137 |
// |
|
138 |
// netLoader.setNodeReader(sdsNodes); |
|
139 |
// netLoader.setEdgeReader(sdsEdges); |
|
140 |
// |
|
141 |
// Graph g = netLoader.loadJungNetwork(); |
|
142 |
// |
|
143 |
// System.out.println("Num nodos=" + g.numVertices() + " numEdges = " |
|
144 |
// + g.numEdges()); |
|
145 |
// |
|
146 |
// // Probamos la algoritmia: distancia entre nodo 1 y nodo 1000 |
|
147 |
// DijkstraDistance distCalculator = new DijkstraDistance(g, |
|
148 |
// new EdgeWeightLabeller()); |
|
149 |
// ArchetypeVertex vOrig = netLoader.getIndexer().getVertex(1); |
|
150 |
// ArchetypeVertex vEnd = netLoader.getIndexer().getVertex(1000); |
|
151 |
// long t1 = System.currentTimeMillis(); |
|
152 |
// Number dist = distCalculator.getDistance(vOrig, vEnd); |
|
153 |
// long t2 = System.currentTimeMillis(); |
|
154 |
// |
|
155 |
// // assertEquals(dist.doubleValue(), 8887, 0); |
|
156 |
// |
|
157 |
// System.out |
|
158 |
// .println("dist =" + dist + " meters. msecs: " + (t2 - t1)); |
|
159 |
// System.out.println(vOrig + " - " + vEnd); |
|
160 |
// System.out.println(vOrig.getUserDatum("X") + ", " |
|
161 |
// + vOrig.getUserDatum("Y") + " - " + vEnd.getUserDatum("X") |
|
162 |
// + ", " + vEnd.getUserDatum("Y")); |
|
163 |
// |
|
164 |
// } catch (DriverLoadException e) { |
|
165 |
// // TODO Auto-generated catch block |
|
166 |
// e.printStackTrace(); |
|
167 |
// } catch (NoSuchTableException e) { |
|
168 |
// // TODO Auto-generated catch block |
|
169 |
// e.printStackTrace(); |
|
170 |
// } catch (DriverException e) { |
|
171 |
// // TODO Auto-generated catch block |
|
172 |
// e.printStackTrace(); |
|
173 |
// } |
|
174 |
// |
|
175 |
// } |
|
126 | 176 |
|
127 |
DataSource dsNodes; |
|
128 |
try { |
|
129 |
dsNodes = dsf.createRandomDataSource("nodes", |
|
130 |
DataSourceFactory.MANUAL_OPENING); |
|
131 |
|
|
132 |
DataSource dsEdges = dsf.createRandomDataSource("edges", |
|
133 |
DataSourceFactory.MANUAL_OPENING); |
|
134 |
|
|
135 |
SelectableDataSource sdsNodes = new SelectableDataSource(dsNodes); |
|
136 |
SelectableDataSource sdsEdges = new SelectableDataSource(dsEdges); |
|
137 |
|
|
138 |
netLoader.setNodeReader(sdsNodes); |
|
139 |
netLoader.setEdgeReader(sdsEdges); |
|
140 |
|
|
141 |
Graph g = netLoader.loadJungNetwork(); |
|
142 |
|
|
143 |
System.out.println("Num nodos=" + g.numVertices() + " numEdges = " |
|
144 |
+ g.numEdges()); |
|
145 |
|
|
146 |
// Probamos la algoritmia: distancia entre nodo 1 y nodo 1000 |
|
147 |
DijkstraDistance distCalculator = new DijkstraDistance(g, |
|
148 |
new EdgeWeightLabeller()); |
|
149 |
ArchetypeVertex vOrig = netLoader.getIndexer().getVertex(1); |
|
150 |
ArchetypeVertex vEnd = netLoader.getIndexer().getVertex(1000); |
|
151 |
long t1 = System.currentTimeMillis(); |
|
152 |
Number dist = distCalculator.getDistance(vOrig, vEnd); |
|
153 |
long t2 = System.currentTimeMillis(); |
|
154 |
|
|
155 |
// assertEquals(dist.doubleValue(), 8887, 0); |
|
156 |
|
|
157 |
System.out |
|
158 |
.println("dist =" + dist + " meters. msecs: " + (t2 - t1)); |
|
159 |
System.out.println(vOrig + " - " + vEnd); |
|
160 |
System.out.println(vOrig.getUserDatum("X") + ", " |
|
161 |
+ vOrig.getUserDatum("Y") + " - " + vEnd.getUserDatum("X") |
|
162 |
+ ", " + vEnd.getUserDatum("Y")); |
|
163 |
|
|
164 |
} catch (DriverLoadException e) { |
|
165 |
// TODO Auto-generated catch block |
|
166 |
e.printStackTrace(); |
|
167 |
} catch (NoSuchTableException e) { |
|
168 |
// TODO Auto-generated catch block |
|
169 |
e.printStackTrace(); |
|
170 |
} catch (DriverException e) { |
|
171 |
// TODO Auto-generated catch block |
|
172 |
e.printStackTrace(); |
|
173 |
} |
|
174 |
|
|
175 |
} |
|
176 |
|
|
177 | 177 |
protected void setUp() throws Exception { |
178 | 178 |
// Setup de los drivers |
179 | 179 |
LayerFactory |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src-test/com/iver/cit/gvsig/graphtests/TestOneToMany.java | ||
---|---|---|
9 | 9 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
10 | 10 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
11 | 11 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
12 |
import com.iver.cit.gvsig.graph.GraphException; |
|
12 |
import com.iver.cit.gvsig.graph.core.GraphException;
|
|
13 | 13 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
14 | 14 |
import com.iver.cit.gvsig.graph.core.IGraph; |
15 | 15 |
import com.iver.cit.gvsig.graph.core.Network; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src-test/com/iver/cit/gvsig/graphtests/TestNetworkGvTableWriter.java | ||
---|---|---|
19 | 19 |
import com.iver.cit.gvsig.fmap.edition.writers.dbf.DbfWriter; |
20 | 20 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
21 | 21 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
22 |
import com.iver.cit.gvsig.graph.GraphException; |
|
22 |
import com.iver.cit.gvsig.graph.core.GraphException;
|
|
23 | 23 |
import com.iver.cit.gvsig.graph.core.writers.NetworkFileRedWriter; |
24 | 24 |
import com.iver.cit.gvsig.graph.core.writers.NetworkGvTableWriter; |
25 | 25 |
|
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/NetworkUtils.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.graph; |
|
42 |
|
|
43 |
import java.awt.Color; |
|
44 |
import java.io.File; |
|
45 |
|
|
46 |
import javax.swing.ImageIcon; |
|
47 |
|
|
48 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
49 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
50 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
51 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
52 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
|
53 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
|
54 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
55 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
|
56 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
|
57 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
|
58 |
import com.iver.cit.gvsig.util.GvSession; |
|
59 |
|
|
60 |
public class NetworkUtils { |
|
61 |
static int idSymbolFlag = -1; |
|
62 |
public static void clearBarriersFromGraphics(MapControl mc) { |
|
63 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
64 |
for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
|
65 |
FGraphic aux = graphics.getGraphic(i); |
|
66 |
if (aux.getTag() != null) |
|
67 |
if (aux.getTag().equalsIgnoreCase("BARRIER")) |
|
68 |
graphics.removeGraphic(aux); |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
public static void clearFlagsFromGraphics(MapControl mc) { |
|
73 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
74 |
for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
|
75 |
FGraphic aux = graphics.getGraphic(i); |
|
76 |
if (aux.getTag() != null) |
|
77 |
if (aux.getTag().equalsIgnoreCase("FLAG")) |
|
78 |
graphics.removeGraphic(aux); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
public static void clearFlagFromGraphics(MapControl mc, GvFlag flag) { |
|
83 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
84 |
FGraphic graphic = graphics.getGraphicByObjectTag(flag); |
|
85 |
graphics.removeGraphic(graphic); |
|
86 |
} |
|
87 |
|
|
88 |
public static void clearRouteFromGraphics(MapControl mc) { |
|
89 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
90 |
for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
|
91 |
FGraphic aux = graphics.getGraphic(i); |
|
92 |
if (aux.getTag() != null) |
|
93 |
if (aux.getTag().equalsIgnoreCase("ROUTE")) |
|
94 |
graphics.removeGraphic(aux); |
|
95 |
} |
|
96 |
} |
|
97 |
|
|
98 |
public static File getNetworkFile(FLayer lyr) { |
|
99 |
String directoryName = System.getProperty("java.io.tmpdir"); |
|
100 |
String aux = lyr.getName().replaceAll("\\Q.shp\\E", ".net"); |
|
101 |
File newFile = new File(directoryName + |
|
102 |
File.separator + |
|
103 |
aux); |
|
104 |
return newFile; |
|
105 |
|
|
106 |
} |
|
107 |
|
|
108 |
public static void addGraphicFlag(MapControl mapControl, GvFlag flag) { |
|
109 |
GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer(); |
|
110 |
if (idSymbolFlag == -1) |
|
111 |
{ |
|
112 |
FSymbol simFlag = new FSymbol(FShape.POINT, Color.BLUE); |
|
113 |
simFlag.setSize(24); |
|
114 |
simFlag.setStyle(FConstant.SYMBOL_STYLE_MARKER_IMAGEN); |
|
115 |
ImageIcon icon = new ImageIcon(NetworkUtils.class.getClassLoader() |
|
116 |
.getResource("images/pushpin.png")); |
|
117 |
simFlag.setIcon(icon.getImage()); |
|
118 |
idSymbolFlag = graphicLayer.addSymbol(simFlag); |
|
119 |
} |
|
120 |
IGeometry gAux = ShapeFactory.createPoint2D( |
|
121 |
flag.getOriginalPoint().getX(), flag.getOriginalPoint().getY()); |
|
122 |
FGraphic graphic = new FGraphic(gAux, idSymbolFlag); |
|
123 |
graphic.setTag("FLAG"); |
|
124 |
graphic.setObjectTag(flag); |
|
125 |
graphicLayer.addGraphic(graphic); |
|
126 |
|
|
127 |
} |
|
128 |
} |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/GraphException.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 20-jun-2006 by azabala |
|
3 |
* |
|
4 |
*/ |
|
5 |
package com.iver.cit.gvsig.graph; |
|
6 |
|
|
7 |
/** |
|
8 |
* Exception throwed by any class of the Graph package. |
|
9 |
* @author alzabord |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class GraphException extends Exception { |
|
13 |
public GraphException(Exception e){ |
|
14 |
super(e); |
|
15 |
} |
|
16 |
|
|
17 |
public GraphException(){ |
|
18 |
super(); |
|
19 |
} |
|
20 |
|
|
21 |
public GraphException(String msg){ |
|
22 |
super(msg); |
|
23 |
} |
|
24 |
|
|
25 |
public GraphException(String msg, Exception e){ |
|
26 |
super(msg, e); |
|
27 |
} |
|
28 |
|
|
29 |
|
|
30 |
} |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/TestExtension.java | ||
---|---|---|
69 | 69 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
70 | 70 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
71 | 71 |
import com.iver.cit.gvsig.graph.core.FEdge; |
72 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
72 | 73 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
73 | 74 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
74 | 75 |
import com.iver.cit.gvsig.graph.core.Network; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/ClearBarriersExtension.java | ||
---|---|---|
49 | 49 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
50 | 50 |
import com.iver.cit.gvsig.graph.core.GvModifiedCost; |
51 | 51 |
import com.iver.cit.gvsig.graph.core.Network; |
52 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
52 | 53 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
53 | 54 |
|
54 | 55 |
public class ClearBarriersExtension extends Extension { |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/solvers/OneToManySolver.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.util.ArrayList; |
44 | 44 |
|
45 |
import com.iver.cit.gvsig.graph.GraphException; |
|
46 | 45 |
import com.iver.cit.gvsig.graph.core.AbstractNetSolver; |
46 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
47 | 47 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
48 | 48 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
49 | 49 |
import com.iver.cit.gvsig.graph.core.GvNode; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/solvers/ShortestPathSolverAStar.java | ||
---|---|---|
49 | 49 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
50 | 50 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
51 | 51 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
52 |
import com.iver.cit.gvsig.graph.GraphException; |
|
53 | 52 |
import com.iver.cit.gvsig.graph.core.AbstractNetSolver; |
53 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
54 | 54 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
55 | 55 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
56 | 56 |
import com.iver.cit.gvsig.graph.core.GvNode; |
57 | 57 |
import com.iver.cit.gvsig.graph.core.GvTurn; |
58 | 58 |
import com.iver.cit.gvsig.graph.core.IGraph; |
59 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
59 | 60 |
import com.vividsolutions.jts.geom.Coordinate; |
60 | 61 |
import com.vividsolutions.jts.geom.Geometry; |
61 | 62 |
import com.vividsolutions.jts.geom.GeometryFactory; |
... | ... | |
190 | 191 |
System.out.println("Salgo con node = " + node.getIdNode()); |
191 | 192 |
} |
192 | 193 |
|
193 |
private void populateRoute(GvFlag origin, GvFlag dest, int idStart, int idEnd) throws DriverException { |
|
194 |
private void populateRoute(GvFlag origin, GvFlag dest, int idStart, |
|
195 |
int idEnd) throws DriverException { |
|
194 | 196 |
int idEnlace; |
195 | 197 |
GvNode node; |
196 | 198 |
GvEdge link; |
197 | 199 |
double costeEntrada; |
198 | 200 |
|
199 |
// Trazar el camino desde idEnd hasta idStart hacia atr?s marcando los Enlaces |
|
200 |
|
|
201 |
// Trazar el camino desde idEnd hasta idStart hacia atr?s marcando los |
|
202 |
// Enlaces |
|
203 |
|
|
201 | 204 |
if (idStart == idEnd) |
202 | 205 |
return; |
203 | 206 |
IGraph graph = net.getGraph(); |
... | ... | |
206 | 209 |
VectorialAdapter va = (VectorialAdapter) net.getLayer().getSource(); |
207 | 210 |
try { |
208 | 211 |
va.start(); |
209 |
/* Miramos los nodos de los tramos inicio y final, y cogemos el nodo que tenga el from_link rellenado. E IGUAL A NUMSOLUCGLOBAL!!!! |
|
210 |
A partir de ah?, recorremos hacia atr?s y tenemos el cuerpo principal del shape. Luego, para |
|
211 |
las puntas hay que tener en cuenta los porcentajes, viendo el trozo que est? pegando a los nodos |
|
212 |
que sabemos que est?n en el path |
|
213 |
*/ |
|
212 |
/* |
|
213 |
* Miramos los nodos de los tramos inicio y final, y cogemos el nodo |
|
214 |
* que tenga el from_link rellenado. E IGUAL A NUMSOLUCGLOBAL!!!! A |
|
215 |
* partir de ah?, recorremos hacia atr?s y tenemos el cuerpo |
|
216 |
* principal del shape. Luego, para las puntas hay que tener en |
|
217 |
* cuenta los porcentajes, viendo el trozo que est? pegando a los |
|
218 |
* nodos que sabemos que est?n en el path |
|
219 |
*/ |
|
214 | 220 |
|
215 |
/* 22/9/2003 Corregimos el fallo que hab?a de escribir el shape de atr?s adelante. |
|
216 |
* Guardamos lo que necesitamos en listaShapes y recorremos esa lista guardando los tramos |
|
217 |
* con el sentido adecuado. |
|
218 |
*/ |
|
221 |
/* |
|
222 |
* 22/9/2003 Corregimos el fallo que hab?a de escribir el shape de |
|
223 |
* atr?s adelante. Guardamos lo que necesitamos en listaShapes y |
|
224 |
* recorremos esa lista guardando los tramos con el sentido |
|
225 |
* adecuado. |
|
226 |
*/ |
|
219 | 227 |
|
220 |
/* 3/Febrero/2005 Limpieza de c?digo superfluo y correci?n de un fallo raro. Ahora es m?s simple y parece |
|
221 |
* que no falla. A ver si dura. IDEA: quiz?s se necesite meter el porcentaje en los arcos partidos. |
|
222 |
*/ |
|
228 |
/* |
|
229 |
* 3/Febrero/2005 Limpieza de c?digo superfluo y correci?n de un |
|
230 |
* fallo raro. Ahora es m?s simple y parece que no falla. A ver si |
|
231 |
* dura. IDEA: quiz?s se necesite meter el porcentaje en los arcos |
|
232 |
* partidos. |
|
233 |
*/ |
|
223 | 234 |
|
224 |
// Define a template class for a vector of IDs. |
|
225 |
InfoShp infoShp; |
|
226 |
Stack pilaShapes = new Stack(); |
|
227 |
// typedef stack<CInfoShp> PILAINFO;
|
|
228 |
// PILAINFO pilaShapes;
|
|
235 |
// Define a template class for a vector of IDs.
|
|
236 |
InfoShp infoShp;
|
|
237 |
Stack pilaShapes = new Stack();
|
|
238 |
// typedef stack<CInfoShp> PILAINFO;
|
|
239 |
// PILAINFO pilaShapes;
|
|
229 | 240 |
|
230 |
double costeTramoFinal=-1;
|
|
231 |
GvNode nodeEnd = graph.getNodeByID(idEnd); |
|
232 |
GvEdge finalEdge = graph.getEdgeByID(nodeEnd.getFromLink()); |
|
233 |
costeTramoFinal = finalEdge.getWeight(); |
|
241 |
double costeTramoFinal = -1;
|
|
242 |
GvNode nodeEnd = graph.getNodeByID(idEnd);
|
|
243 |
GvEdge finalEdge = graph.getEdgeByID(nodeEnd.getFromLink());
|
|
244 |
costeTramoFinal = finalEdge.getWeight();
|
|
234 | 245 |
|
235 |
GvNode pNodo; |
|
236 |
GvEdge pEnlace; |
|
237 |
|
|
238 |
boolean bFlipearShape = false; |
|
246 |
GvNode pNodo; |
|
247 |
GvEdge pEnlace; |
|
239 | 248 |
|
240 |
double pctMax, pctMin;
|
|
249 |
boolean bFlipearShape = false;
|
|
241 | 250 |
|
251 |
double pctMax, pctMin; |
|
242 | 252 |
|
253 |
// //////////////////////////////////////////////////////////////////////////////////// |
|
254 |
// Trozo del final |
|
255 |
// El shape va de idStop1 a idStop2, y el porcentaje viene en ese |
|
256 |
// sentido. |
|
257 |
// Si el idEnd es idStop1, quiere decir que el tramo que falta va en |
|
258 |
// ese sentido tambi?n, |
|
259 |
// as? que recorremos ese shape desde idStop1 hasta que rebasemos o |
|
260 |
// igualemos ese porcentaje. |
|
261 |
// Si no, hemos pasado por idStop2 y la parte que hay que meter es |
|
262 |
// desde el pto interior a idStop2 |
|
263 |
// ///////////////////////////////////////////////////////////////////////////////////// |
|
264 |
IFeature feat = va.getFeature(finalEdge.getIdArc()); |
|
265 |
MultiLineString jtsGeom = (MultiLineString) feat.getGeometry() |
|
266 |
.toJTSGeometry(); |
|
267 |
// CoordinateFilter removeDuplicates = new |
|
268 |
// UniqueCoordinateArrayFilter(); |
|
269 |
// jtsGeom.apply(removeDuplicates); |
|
270 |
// jtsGeom.geometryChanged(); |
|
243 | 271 |
|
244 |
////////////////////////////////////////////////////////////////////////////////////// |
|
245 |
// Trozo del final |
|
246 |
// El shape va de idStop1 a idStop2, y el porcentaje viene en ese sentido. |
|
247 |
// Si el idEnd es idStop1, quiere decir que el tramo que falta va en ese sentido tambi?n, |
|
248 |
// as? que recorremos ese shape desde idStop1 hasta que rebasemos o igualemos ese porcentaje. |
|
249 |
// Si no, hemos pasado por idStop2 y la parte que hay que meter es desde el pto interior a idStop2 |
|
250 |
/////////////////////////////////////////////////////////////////////////////////////// |
|
251 |
IFeature feat = va.getFeature(finalEdge.getIdArc()); |
|
252 |
MultiLineString jtsGeom = (MultiLineString) feat.getGeometry().toJTSGeometry(); |
|
253 |
// CoordinateFilter removeDuplicates = new UniqueCoordinateArrayFilter(); |
|
254 |
// jtsGeom.apply(removeDuplicates); |
|
255 |
// jtsGeom.geometryChanged(); |
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
// SI ESTAMOS SOBRE EL MISMO TRAMO, CASO PARTICULAR |
|
260 |
// y el sentido de circulaci?n es correcto |
|
261 |
if ((origin.getIdArc() == dest.getIdArc()) && (nodeEnd.getBestCost() <= costeTramoFinal)) |
|
262 |
{ |
|
263 |
if (dest.getPct() > origin.getPct()) |
|
264 |
{ |
|
265 |
pctMax = dest.getPct(); |
|
266 |
pctMin = origin.getPct(); |
|
267 |
} |
|
268 |
else |
|
269 |
{ |
|
270 |
pctMax = origin.getPct(); |
|
271 |
pctMin = dest.getPct(); |
|
272 |
bFlipearShape = true; |
|
273 |
} |
|
272 |
// SI ESTAMOS SOBRE EL MISMO TRAMO, CASO PARTICULAR |
|
273 |
// y el sentido de circulaci?n es correcto |
|
274 |
if ((origin.getIdArc() == dest.getIdArc()) |
|
275 |
&& (nodeEnd.getBestCost() <= costeTramoFinal)) { |
|
276 |
if (dest.getPct() > origin.getPct()) { |
|
277 |
pctMax = dest.getPct(); |
|
278 |
pctMin = origin.getPct(); |
|
279 |
} else { |
|
280 |
pctMax = origin.getPct(); |
|
281 |
pctMin = dest.getPct(); |
|
282 |
bFlipearShape = true; |
|
283 |
} |
|
274 | 284 |
|
275 |
LineString line = SituaSobreTramo(jtsGeom,dest.getIdArc(), dest.getPct(),1); |
|
276 |
|
|
277 |
pctMin = pctMin / pctMax; // Porque ha cambiado la longitud del shape |
|
285 |
LineString line = NetworkUtils.getPartialLineString(jtsGeom, |
|
286 |
pctMax, 1); |
|
278 | 287 |
|
279 |
line = SituaSobreTramo(line,dest.getIdArc(), pctMin,0); |
|
288 |
pctMin = pctMin / pctMax; // Porque ha cambiado la longitud |
|
289 |
// del shape |
|
280 | 290 |
|
281 |
if (bFlipearShape) |
|
282 |
line = line.reverse(); |
|
283 |
|
|
284 |
IGeometry geom = FConverter.jts_to_igeometry(line); |
|
285 |
// TODO: Calcular bien el length de este arco, |
|
286 |
// basandonos en el porcentaje costeTramoFinal / costeOriginal |
|
287 |
route.addRouteFeature(geom, origin.getIdArc(), |
|
288 |
costeTramoFinal, line.getLength(), feat.getAttribute(getFieldIndexStreetName()).toString()); |
|
291 |
line = NetworkUtils.getPartialLineString(line, pctMin, 0); |
|
289 | 292 |
|
293 |
if (bFlipearShape) |
|
294 |
line = line.reverse(); |
|
290 | 295 |
|
291 |
return ; // Deber?a sacar el coste |
|
292 |
} |
|
296 |
IGeometry geom = FConverter.jts_to_igeometry(line); |
|
297 |
// TODO: Calcular bien el length de este arco, |
|
298 |
// basandonos en el porcentaje costeTramoFinal / costeOriginal |
|
299 |
route.addRouteFeature(geom, origin.getIdArc(), costeTramoFinal, |
|
300 |
line.getLength(), feat.getAttribute( |
|
301 |
getFieldIndexStreetName()).toString()); |
|
293 | 302 |
|
294 |
|
|
303 |
return; // Deber?a sacar el coste |
|
304 |
} |
|
295 | 305 |
|
296 |
// Trazar el camino desde idEnd hasta idStart hacia atr?s marcando los Enlaces |
|
297 |
pNodo = graph.getNodeByID(idEnd); |
|
306 |
// Trazar el camino desde idEnd hasta idStart hacia atr?s marcando |
|
307 |
// los Enlaces |
|
308 |
pNodo = graph.getNodeByID(idEnd); |
|
298 | 309 |
|
299 |
while ((pNodo.getIdNode() != idStart)) |
|
300 |
{ |
|
301 |
idEnlace = pNodo.getFromLink(); |
|
302 |
pEnlace = graph.getEdgeByID(idEnlace); |
|
310 |
while ((pNodo.getIdNode() != idStart)) { |
|
311 |
idEnlace = pNodo.getFromLink(); |
|
312 |
pEnlace = graph.getEdgeByID(idEnlace); |
|
303 | 313 |
|
304 |
pNodo = graph.getNodeByID(pEnlace.getIdNodeOrig()); |
|
305 |
|
|
306 |
infoShp = new InfoShp(); |
|
307 |
infoShp.distance = pEnlace.getDistance(); |
|
308 |
infoShp.cost = pEnlace.getWeight(); |
|
314 |
pNodo = graph.getNodeByID(pEnlace.getIdNodeOrig()); |
|
309 | 315 |
|
310 |
if ((pEnlace.getIdArc() == origin.getIdArc()) || (pEnlace.getIdArc() == dest.getIdArc())) |
|
311 |
{ |
|
312 |
if (pEnlace.getIdArc() == origin.getIdArc()) |
|
313 |
{ |
|
314 |
infoShp.pct = origin.getPct(); |
|
315 |
infoShp.idArc = origin.getIdArc(); |
|
316 |
if (pEnlace.getDirec() == 0) |
|
317 |
{ |
|
318 |
infoShp.direction = 1; |
|
319 |
infoShp.bFlip = true; |
|
316 |
infoShp = new InfoShp(); |
|
317 |
infoShp.distance = pEnlace.getDistance(); |
|
318 |
infoShp.cost = pEnlace.getWeight(); |
|
319 |
|
|
320 |
if ((pEnlace.getIdArc() == origin.getIdArc()) |
|
321 |
|| (pEnlace.getIdArc() == dest.getIdArc())) { |
|
322 |
if (pEnlace.getIdArc() == origin.getIdArc()) { |
|
323 |
infoShp.pct = origin.getPct(); |
|
324 |
infoShp.idArc = origin.getIdArc(); |
|
325 |
if (pEnlace.getDirec() == 0) { |
|
326 |
infoShp.direction = 1; |
|
327 |
infoShp.bFlip = true; |
|
328 |
} else // Hemos pasado por el 2 |
|
329 |
{ |
|
330 |
infoShp.direction = 0; |
|
331 |
infoShp.bFlip = false; |
|
332 |
} // if else */ |
|
333 |
} else { |
|
334 |
infoShp.pct = dest.getPct(); |
|
335 |
infoShp.idArc = dest.getIdArc(); |
|
336 |
if (pEnlace.getDirec() == 0) { |
|
337 |
infoShp.direction = 0; |
|
338 |
infoShp.bFlip = true; |
|
339 |
} else { |
|
340 |
infoShp.direction = 1; |
|
341 |
infoShp.bFlip = false; |
|
342 |
} // if else */ |
|
320 | 343 |
} |
321 |
else // Hemos pasado por el 2 |
|
322 |
{ |
|
323 |
infoShp.direction = 0; |
|
344 |
} else { |
|
345 |
infoShp.pct = 1.0; |
|
346 |
infoShp.idArc = pEnlace.getIdArc(); |
|
347 |
|
|
348 |
infoShp.direction = 1; |
|
349 |
if (pEnlace.getDirec() == 1) |
|
324 | 350 |
infoShp.bFlip = false; |
325 |
} // if else */ |
|
326 |
} |
|
327 |
else |
|
328 |
{ |
|
329 |
infoShp.pct = dest.getPct(); |
|
330 |
infoShp.idArc = dest.getIdArc(); |
|
331 |
if (pEnlace.getDirec() == 0) |
|
332 |
{ |
|
333 |
infoShp.direction = 0; |
|
334 |
infoShp.bFlip = true; |
|
335 |
} |
|
336 | 351 |
else |
337 |
{ |
|
338 |
infoShp.direction = 1; |
|
339 |
infoShp.bFlip = false; |
|
340 |
} // if else */ |
|
352 |
infoShp.bFlip = true; |
|
341 | 353 |
} |
354 |
|
|
355 |
pilaShapes.push(infoShp); |
|
342 | 356 |
} |
343 |
else |
|
344 |
{ |
|
345 |
infoShp.pct = 1.0; |
|
346 |
infoShp.idArc = pEnlace.getIdArc(); |
|
347 |
|
|
348 |
infoShp.direction =1; |
|
349 |
if (pEnlace.getDirec() == 1) |
|
350 |
infoShp.bFlip = false; |
|
351 |
else |
|
352 |
infoShp.bFlip = true; |
|
353 |
} |
|
354 | 357 |
|
355 |
pilaShapes.push(infoShp); |
|
356 |
} |
|
358 |
// Y ahora recorremos hacia atr?s el vector y escribimos los shapes. |
|
359 |
// VECTORINFO::iterator theIterator; |
|
360 |
int auxC = 0; |
|
357 | 361 |
|
358 |
// Y ahora recorremos hacia atr?s el vector y escribimos los shapes. |
|
359 |
// VECTORINFO::iterator theIterator; |
|
360 |
int auxC = 0; |
|
361 |
|
|
362 |
while (!pilaShapes.empty()) |
|
363 |
{ |
|
364 |
infoShp = (InfoShp) pilaShapes.peek(); |
|
365 |
feat = va.getFeature(infoShp.idArc); |
|
366 |
MultiLineString line = (MultiLineString) feat.getGeometry().toJTSGeometry(); |
|
367 |
// line.apply(removeDuplicates); |
|
368 |
// line.geometryChanged(); |
|
369 |
|
|
370 |
LineString aux = null; |
|
371 |
if (infoShp.pct < 1.0) |
|
372 |
aux = SituaSobreTramo(line,infoShp.idArc, infoShp.pct, infoShp.direction); |
|
362 |
while (!pilaShapes.empty()) { |
|
363 |
infoShp = (InfoShp) pilaShapes.peek(); |
|
364 |
feat = va.getFeature(infoShp.idArc); |
|
365 |
MultiLineString line = (MultiLineString) feat.getGeometry() |
|
366 |
.toJTSGeometry(); |
|
367 |
// line.apply(removeDuplicates); |
|
368 |
// line.geometryChanged(); |
|
373 | 369 |
|
374 |
IGeometry geom = null; |
|
375 |
if (aux == null) |
|
376 |
{ |
|
377 |
if (infoShp.bFlip) |
|
378 |
line = line.reverse(); |
|
379 |
geom = FConverter.jts_to_igeometry(line); |
|
380 |
} |
|
381 |
else |
|
382 |
{ |
|
383 |
if (infoShp.bFlip) |
|
384 |
aux = aux.reverse(); |
|
385 |
geom = FConverter.jts_to_igeometry(aux); |
|
386 |
} |
|
370 |
LineString aux = null; |
|
371 |
if (infoShp.pct < 1.0) |
|
372 |
aux = NetworkUtils.getPartialLineString(line, infoShp.pct, |
|
373 |
infoShp.direction); |
|
387 | 374 |
|
375 |
IGeometry geom = null; |
|
376 |
if (aux == null) { |
|
377 |
if (infoShp.bFlip) |
|
378 |
line = line.reverse(); |
|
379 |
geom = FConverter.jts_to_igeometry(line); |
|
380 |
} else { |
|
381 |
if (infoShp.bFlip) |
|
382 |
aux = aux.reverse(); |
|
383 |
geom = FConverter.jts_to_igeometry(aux); |
|
384 |
} |
|
388 | 385 |
|
389 |
route.addRouteFeature(geom, infoShp.idArc, |
|
390 |
infoShp.cost, infoShp.distance, feat.getAttribute(getFieldIndexStreetName()).toString()); |
|
386 |
route.addRouteFeature(geom, infoShp.idArc, infoShp.cost, |
|
387 |
infoShp.distance, feat.getAttribute( |
|
388 |
getFieldIndexStreetName()).toString()); |
|
391 | 389 |
|
390 |
pilaShapes.pop(); |
|
391 |
auxC++; |
|
392 | 392 |
|
393 |
pilaShapes.pop(); |
|
394 |
auxC++; |
|
395 |
|
|
396 |
} |
|
397 |
va.stop(); |
|
398 |
} catch (DriverIOException e) { |
|
393 |
} |
|
394 |
va.stop(); |
|
395 |
} catch (Exception e) { |
|
399 | 396 |
// TODO Auto-generated catch block |
400 | 397 |
e.printStackTrace(); |
401 | 398 |
} |
402 | 399 |
|
403 | 400 |
return; |
404 | 401 |
|
405 |
|
|
406 | 402 |
} |
407 | 403 |
|
408 | 404 |
LineString SituaSobreTramo(Geometry geom, int idArc, double pct, int parte) |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/solvers/ShortestPathSolverDijkstra.java | ||
---|---|---|
48 | 48 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
49 | 49 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
50 | 50 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
51 |
import com.iver.cit.gvsig.graph.GraphException; |
|
52 | 51 |
import com.iver.cit.gvsig.graph.core.AbstractNetSolver; |
52 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
53 | 53 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
54 | 54 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
55 | 55 |
import com.iver.cit.gvsig.graph.core.GvNode; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/tools/BarrierListener.java | ||
---|---|---|
64 | 64 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
65 | 65 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
66 | 66 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener; |
67 |
import com.iver.cit.gvsig.graph.GraphException; |
|
68 | 67 |
import com.iver.cit.gvsig.graph.core.EdgePair; |
68 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
69 | 69 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
70 | 70 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
71 | 71 |
import com.iver.cit.gvsig.graph.core.Network; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/tools/FlagListener.java | ||
---|---|---|
64 | 64 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
65 | 65 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
66 | 66 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener; |
67 |
import com.iver.cit.gvsig.graph.GraphException; |
|
68 |
import com.iver.cit.gvsig.graph.NetworkUtils; |
|
67 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
69 | 68 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
70 | 69 |
import com.iver.cit.gvsig.graph.core.Network; |
70 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
71 | 71 |
|
72 | 72 |
public class FlagListener implements PointListener { |
73 | 73 |
public static final int TO_ARC = 0; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/ODMatrixExtension.java | ||
---|---|---|
55 | 55 |
import com.iver.cit.gvsig.fmap.MapControl; |
56 | 56 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
57 | 57 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
58 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
58 | 59 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
59 | 60 |
import com.iver.cit.gvsig.graph.core.Network; |
60 | 61 |
import com.iver.cit.gvsig.graph.solvers.OneToManySolver; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/ShortestPathExtension.java | ||
---|---|---|
62 | 62 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
63 | 63 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
64 | 64 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
65 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
65 | 66 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
66 | 67 |
import com.iver.cit.gvsig.graph.core.IFlagListener; |
67 | 68 |
import com.iver.cit.gvsig.graph.core.Network; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/LoadNetworkExtension.java | ||
---|---|---|
63 | 63 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
64 | 64 |
import com.iver.cit.gvsig.graph.core.IGraph; |
65 | 65 |
import com.iver.cit.gvsig.graph.core.Network; |
66 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
66 | 67 |
import com.iver.cit.gvsig.graph.core.loaders.NetworkLoader; |
67 | 68 |
import com.iver.cit.gvsig.graph.core.loaders.NetworkRedLoader; |
68 | 69 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/ServiceAreaExtension.java | ||
---|---|---|
62 | 62 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
63 | 63 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
64 | 64 |
import com.iver.cit.gvsig.fmap.rendering.FGraphicLabel; |
65 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
65 | 66 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
66 | 67 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
67 | 68 |
import com.iver.cit.gvsig.graph.core.GvNode; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/ClearFlagsExtension.java | ||
---|---|---|
48 | 48 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
49 | 49 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
50 | 50 |
import com.iver.cit.gvsig.graph.core.Network; |
51 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
51 | 52 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
52 | 53 |
|
53 | 54 |
public class ClearFlagsExtension extends Extension { |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/GenerateNetworkExtension.java | ||
---|---|---|
72 | 72 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
73 | 73 |
import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessException; |
74 | 74 |
import com.iver.cit.gvsig.geoprocess.core.fmap.XTypes; |
75 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
75 | 76 |
import com.iver.cit.gvsig.graph.core.writers.NetworkFileRedWriter; |
76 | 77 |
import com.iver.cit.gvsig.graph.core.writers.NetworkGvTableWriter; |
77 | 78 |
import com.iver.cit.gvsig.graph.gui.wizard.NetWizard; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/ClearRouteExtension.java | ||
---|---|---|
52 | 52 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
53 | 53 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
54 | 54 |
import com.iver.cit.gvsig.graph.core.Network; |
55 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
55 | 56 |
import com.iver.cit.gvsig.graph.gui.RouteReportPanel; |
56 | 57 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
57 | 58 |
import com.iver.cit.gvsig.util.GvSession; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/gui/RouteControlPanel.java | ||
---|---|---|
208 | 208 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial; |
209 | 209 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
210 | 210 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
211 |
import com.iver.cit.gvsig.graph.GraphException; |
|
212 |
import com.iver.cit.gvsig.graph.NetworkUtils; |
|
211 |
import com.iver.cit.gvsig.graph.core.GraphException; |
|
213 | 212 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
214 | 213 |
import com.iver.cit.gvsig.graph.core.GvFlag; |
215 | 214 |
import com.iver.cit.gvsig.graph.core.IFlagListener; |
216 | 215 |
import com.iver.cit.gvsig.graph.core.Network; |
216 |
import com.iver.cit.gvsig.graph.core.NetworkUtils; |
|
217 | 217 |
import com.iver.cit.gvsig.graph.solvers.FlagsMemoryDriver; |
218 | 218 |
import com.iver.cit.gvsig.graph.solvers.Route; |
219 | 219 |
import com.iver.cit.gvsig.graph.solvers.RouteMemoryDriver; |
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/core/GvFlag.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.awt.geom.Point2D; |
44 | 44 |
|
45 |
import com.iver.andami.PluginServices; |
|
46 |
|
|
47 | 45 |
public class GvFlag { |
48 | 46 |
/* |
49 | 47 |
* Indexes of flag features' fields. |
... | ... | |
78 | 76 |
|
79 | 77 |
public GvFlag(double x, double y) { |
80 | 78 |
this.originalPoint = new Point2D.Double(x, y); |
81 |
this.description = PluginServices.getText(this, "new_flag")+flagNumber++; |
|
79 |
// this.description = PluginServices.getText(this, "new_flag")+flagNumber++; |
|
80 |
this.description = "flag"+flagNumber++; |
|
82 | 81 |
} |
83 | 82 |
|
84 | 83 |
public GvFlag(double x, double y, double cost) { |
85 | 84 |
this.originalPoint = new Point2D.Double(x, y); |
86 |
this.description = PluginServices.getText(this, "new_flag")+flagNumber++; |
|
85 |
// this.description = PluginServices.getText(this, "new_flag")+flagNumber++; |
|
86 |
this.description = "flag"+flagNumber++; |
|
87 | 87 |
this.cost = cost; |
88 | 88 |
} |
89 | 89 |
|
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/core/loaders/NetworkRedLoader.java | ||
---|---|---|
47 | 47 |
import java.nio.ByteOrder; |
48 | 48 |
import java.nio.MappedByteBuffer; |
49 | 49 |
import java.nio.channels.FileChannel; |
50 |
import java.util.ArrayList; |
|
51 | 50 |
|
52 |
import javax.imageio.stream.FileImageOutputStream; |
|
53 |
|
|
54 | 51 |
import com.iver.cit.gvsig.graph.core.EdgePair; |
55 | 52 |
import com.iver.cit.gvsig.graph.core.GvEdge; |
56 | 53 |
import com.iver.cit.gvsig.graph.core.GvGraph; |
... | ... | |
58 | 55 |
import com.iver.cit.gvsig.graph.core.IGraph; |
59 | 56 |
import com.iver.cit.gvsig.graph.core.INetworkLoader; |
60 | 57 |
|
61 |
import edu.uci.ics.jung.graph.Graph; |
|
62 |
import edu.uci.ics.jung.graph.Vertex; |
|
63 |
import edu.uci.ics.jung.graph.decorators.Indexer; |
|
64 |
import edu.uci.ics.jung.graph.impl.DirectedSparseEdge; |
|
65 |
import edu.uci.ics.jung.graph.impl.DirectedSparseVertex; |
|
66 |
import edu.uci.ics.jung.graph.impl.SparseGraph; |
|
67 |
|
|
68 | 58 |
/** |
69 | 59 |
* @author fjp |
70 | 60 |
* |
... | ... | |
74 | 64 |
*/ |
75 | 65 |
public class NetworkRedLoader implements INetworkLoader { |
76 | 66 |
|
77 |
private File netFile = new File("c:/ejes.red");
|
|
67 |
private File netFile = new File("c:/ejes.net");
|
|
78 | 68 |
|
79 | 69 |
public IGraph loadNetwork() { |
80 | 70 |
|
... | ... | |
160 | 150 |
return null; |
161 | 151 |
} |
162 | 152 |
|
163 |
public Graph loadJungNetwork() |
|
164 |
{ |
|
165 |
SparseGraph g = new SparseGraph(); |
|
166 |
long t1 = System.currentTimeMillis(); |
|
167 |
|
|
168 |
RandomAccessFile file; |
|
169 |
try { |
|
170 |
file = new RandomAccessFile(netFile.getPath(), |
|
171 |
"r"); |
|
172 |
FileChannel channel = file.getChannel(); |
|
173 |
MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); |
|
174 |
buf.order(ByteOrder.LITTLE_ENDIAN); |
|
153 |
// public Graph loadJungNetwork() |
|
154 |
// { |
|
155 |
// SparseGraph g = new SparseGraph(); |
|
156 |
// long t1 = System.currentTimeMillis(); |
|
157 |
// |
|
158 |
// RandomAccessFile file; |
|
159 |
// try { |
|
160 |
// file = new RandomAccessFile(netFile.getPath(), |
|
161 |
// "r"); |
|
162 |
// FileChannel channel = file.getChannel(); |
|
163 |
// MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); |
|
164 |
// buf.order(ByteOrder.LITTLE_ENDIAN); |
|
165 |
// |
|
166 |
// int numArcs = buf.getInt(); |
|
167 |
// int numEdges = buf.getInt(); |
|
168 |
// int numNodes = buf.getInt(); |
|
169 |
// |
|
170 |
// // Nodes |
|
171 |
// buf.position(24*numEdges + 12); |
|
172 |
// for (int i=0; i < numNodes; i++) |
|
173 |
// { |
|
174 |
// GvNode node = readNode(buf); |
|
175 |
// |
|
176 |
// Vertex v = new DirectedSparseVertex(); |
|
177 |
//// v.addUserDatum("ID", node.idNode, UserData.CLONE); |
|
178 |
//// v.addUserDatum("X", node.x, UserData.CLONE); |
|
179 |
//// v.addUserDatum("Y", node.y, UserData.CLONE); |
|
180 |
// // v_locations.setLocation(v, new Point2D.Double(x.doubleValue(),y.doubleValue())); |
|
181 |
// g.addVertex(v); |
|
182 |
// } |
|
183 |
// Indexer indexer = Indexer.getIndexer(g); |
|
184 |
// |
|
185 |
// buf.position(12); |
|
186 |
// for (int i=0; i < numEdges; i++) |
|
187 |
// { |
|
188 |
// GvEdge edge = readEdge(buf); |
|
189 |
// |
|
190 |
// int nodeOrig = edge.getIdNodeOrig(); |
|
191 |
// int nodeEnd = edge.getIdNodeEnd(); |
|
192 |
// |
|
193 |
// Vertex vFrom = (Vertex) indexer.getVertex(nodeOrig); |
|
194 |
// Vertex vTo = (Vertex) indexer.getVertex(nodeEnd); |
|
195 |
// |
|
196 |
// DirectedSparseEdge edgeJ = new DirectedSparseEdge(vFrom, vTo); |
|
197 |
// g.addEdge(edgeJ); |
|
198 |
// } |
|
199 |
// long t2 = System.currentTimeMillis(); |
|
200 |
// System.out.println("Tiempo de carga: " + (t2-t1) + " msecs"); |
|
201 |
// return g; |
|
202 |
// } catch (FileNotFoundException e) { |
|
203 |
// // TODO Auto-generated catch block |
|
204 |
// e.printStackTrace(); |
|
205 |
// } catch (IOException e) { |
|
206 |
// // TODO Auto-generated catch block |
|
207 |
// e.printStackTrace(); |
|
208 |
// } |
|
209 |
// return null; |
|
210 |
// } |
|
175 | 211 |
|
176 |
int numArcs = buf.getInt(); |
|
177 |
int numEdges = buf.getInt(); |
|
178 |
int numNodes = buf.getInt(); |
|
179 |
|
|
180 |
// Nodes |
|
181 |
buf.position(24*numEdges + 12); |
|
182 |
for (int i=0; i < numNodes; i++) |
|
183 |
{ |
|
184 |
GvNode node = readNode(buf); |
|
185 |
|
|
186 |
Vertex v = new DirectedSparseVertex(); |
|
187 |
// v.addUserDatum("ID", node.idNode, UserData.CLONE); |
|
188 |
// v.addUserDatum("X", node.x, UserData.CLONE); |
|
189 |
// v.addUserDatum("Y", node.y, UserData.CLONE); |
|
190 |
// v_locations.setLocation(v, new Point2D.Double(x.doubleValue(),y.doubleValue())); |
|
191 |
g.addVertex(v); |
|
192 |
} |
|
193 |
Indexer indexer = Indexer.getIndexer(g); |
|
194 |
|
|
195 |
buf.position(12); |
|
196 |
for (int i=0; i < numEdges; i++) |
|
197 |
{ |
|
198 |
GvEdge edge = readEdge(buf); |
|
199 |
|
|
200 |
int nodeOrig = edge.getIdNodeOrig(); |
|
201 |
int nodeEnd = edge.getIdNodeEnd(); |
|
202 |
|
|
203 |
Vertex vFrom = (Vertex) indexer.getVertex(nodeOrig); |
|
204 |
Vertex vTo = (Vertex) indexer.getVertex(nodeEnd); |
|
205 |
|
|
206 |
DirectedSparseEdge edgeJ = new DirectedSparseEdge(vFrom, vTo); |
|
207 |
g.addEdge(edgeJ); |
|
208 |
} |
|
209 |
long t2 = System.currentTimeMillis(); |
|
210 |
System.out.println("Tiempo de carga: " + (t2-t1) + " msecs"); |
|
211 |
return g; |
|
212 |
} catch (FileNotFoundException e) { |
|
213 |
// TODO Auto-generated catch block |
|
214 |
e.printStackTrace(); |
|
215 |
} catch (IOException e) { |
|
216 |
// TODO Auto-generated catch block |
|
217 |
e.printStackTrace(); |
|
218 |
} |
|
219 |
return null; |
|
220 |
} |
|
221 |
|
|
222 | 212 |
private GvNode readNode(MappedByteBuffer buf) { |
223 | 213 |
GvNode node = new GvNode(); |
224 | 214 |
node.setIdNode(buf.getInt()); |
... | ... | |
283 | 273 |
NetworkRedLoader redLoader = new NetworkRedLoader(); |
284 | 274 |
|
285 | 275 |
redLoader.loadNetwork(); |
286 |
redLoader.loadJungNetwork(); |
|
276 |
// redLoader.loadJungNetwork();
|
|
287 | 277 |
|
288 | 278 |
} |
289 | 279 |
|
tags/v1_1_2_Build_1044/prototypes/VectorialAvanzado/extensions/extGraph/src/com/iver/cit/gvsig/graph/core/NetworkUtils.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.graph.core; |
|
42 |
|
|
43 |
import java.awt.Color; |
|
44 |
import java.io.File; |
|
45 |
import java.util.ArrayList; |
|
46 |
|
|
47 |
import javax.swing.ImageIcon; |
|
48 |
|
|
49 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
50 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
51 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
52 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
53 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
|
54 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
|
55 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
56 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
|
57 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
|
58 |
import com.vividsolutions.jts.geom.Coordinate; |
|
59 |
import com.vividsolutions.jts.geom.Geometry; |
|
60 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
61 |
import com.vividsolutions.jts.geom.LineString; |
|
62 |
|
|
63 |
public class NetworkUtils { |
|
64 |
static int idSymbolFlag = -1; |
|
65 |
|
|
66 |
static private GeometryFactory geomFactory = new GeometryFactory(); |
|
67 |
|
|
68 |
public static void clearBarriersFromGraphics(MapControl mc) { |
|
69 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
70 |
for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
|
71 |
FGraphic aux = graphics.getGraphic(i); |
|
72 |
if (aux.getTag() != null) |
|
73 |
if (aux.getTag().equalsIgnoreCase("BARRIER")) |
|
74 |
graphics.removeGraphic(aux); |
|
75 |
} |
|
76 |
} |
|
77 |
|
|
78 |
public static void clearFlagsFromGraphics(MapControl mc) { |
|
79 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
80 |
for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
|
81 |
FGraphic aux = graphics.getGraphic(i); |
|
82 |
if (aux.getTag() != null) |
|
83 |
if (aux.getTag().equalsIgnoreCase("FLAG")) |
|
84 |
graphics.removeGraphic(aux); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
public static void clearFlagFromGraphics(MapControl mc, GvFlag flag) { |
|
89 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
90 |
FGraphic graphic = graphics.getGraphicByObjectTag(flag); |
|
91 |
graphics.removeGraphic(graphic); |
|
92 |
} |
|
93 |
|
|
94 |
public static void clearRouteFromGraphics(MapControl mc) { |
|
95 |
GraphicLayer graphics = mc.getMapContext().getGraphicsLayer(); |
|
96 |
for (int i = graphics.getNumGraphics() - 1; i >= 0; i--) { |
|
97 |
FGraphic aux = graphics.getGraphic(i); |
|
98 |
if (aux.getTag() != null) |
|
99 |
if (aux.getTag().equalsIgnoreCase("ROUTE")) |
|
100 |
graphics.removeGraphic(aux); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
public static File getNetworkFile(FLayer lyr) { |
|
105 |
String directoryName = System.getProperty("java.io.tmpdir"); |
|
106 |
String aux = lyr.getName().replaceAll("\\Q.shp\\E", ".net"); |
|
107 |
File newFile = new File(directoryName + |
|
108 |
File.separator + |
|
109 |
aux); |
|
110 |
return newFile; |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
public static void addGraphicFlag(MapControl mapControl, GvFlag flag) { |
|
115 |
GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer(); |
|
116 |
if (idSymbolFlag == -1) |
|
117 |
{ |
|
118 |
FSymbol simFlag = new FSymbol(FShape.POINT, Color.BLUE); |
|
119 |
simFlag.setSize(24); |
|
120 |
simFlag.setStyle(FConstant.SYMBOL_STYLE_MARKER_IMAGEN); |
|
121 |
ImageIcon icon = new ImageIcon(NetworkUtils.class.getClassLoader() |
|
122 |
.getResource("images/pushpin.png")); |
|
123 |
simFlag.setIcon(icon.getImage()); |
|
124 |
idSymbolFlag = graphicLayer.addSymbol(simFlag); |
|
125 |
} |
|
126 |
IGeometry gAux = ShapeFactory.createPoint2D( |
|
127 |
flag.getOriginalPoint().getX(), flag.getOriginalPoint().getY()); |
|
128 |
FGraphic graphic = new FGraphic(gAux, idSymbolFlag); |
|
129 |
graphic.setTag("FLAG"); |
|
130 |
graphic.setObjectTag(flag); |
|
131 |
graphicLayer.addGraphic(graphic); |
|
132 |
|
|
133 |
} |
|
134 |
|
Also available in: Unified diff