Revision 22945
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/ISolveErrorListener.java | ||
---|---|---|
1 |
|
|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
3 |
* |
|
4 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
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 2 |
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
19 |
* |
|
20 |
* For more information, contact: |
|
21 |
* |
|
22 |
* Generalitat Valenciana |
|
23 |
* Conselleria d'Infraestructures i Transport |
|
24 |
* Av. Blasco Ib??ez, 50 |
|
25 |
* 46010 VALENCIA |
|
26 |
* SPAIN |
|
27 |
* |
|
28 |
* +34 963862235 |
|
29 |
* gvsig@gva.es |
|
30 |
* www.gvsig.gva.es |
|
31 |
* |
|
32 |
* or |
|
33 |
* |
|
34 |
* IVER T.I. S.A |
|
35 |
* Salamanca 50 |
|
36 |
* 46005 Valencia |
|
37 |
* Spain |
|
38 |
* |
|
39 |
* +34 963163400 |
|
40 |
* dac@iver.es |
|
41 |
*/ |
|
42 |
|
|
43 |
package org.gvsig.fmap.mapcontext.layers; |
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* Interface to solve one error al layer |
|
50 |
* |
|
51 |
* @author Vicente Caballero Navarro |
|
52 |
*/ |
|
53 |
public interface ISolveErrorListener { |
|
54 |
/** |
|
55 |
* Return the class to string of the exception to solve. |
|
56 |
* |
|
57 |
* @return Class exception |
|
58 |
*/ |
|
59 |
public String getException(); |
|
60 |
|
|
61 |
/** |
|
62 |
* Solve the error and return the layer solved. |
|
63 |
* |
|
64 |
* @param layer Layer with error |
|
65 |
* @param driver Driver of layer. |
|
66 |
* |
|
67 |
* @return Layer solved. |
|
68 |
*/ |
|
69 |
public FLayer solve(FLayer layer);//, Driver driver); |
|
70 |
|
|
71 |
/** |
|
72 |
* Return true if the layer has been solved. |
|
73 |
* |
|
74 |
* @return True if the layer has been solved. |
|
75 |
*/ |
|
76 |
public boolean isSolved(); |
|
77 |
} |
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/FLyrVectLinkProperties.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontext.layers; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
import java.io.File; |
|
5 |
import java.net.URI; |
|
6 |
import java.net.URISyntaxException; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.Iterator; |
|
9 |
|
|
10 |
import org.gvsig.fmap.data.ReadException; |
|
11 |
import org.gvsig.fmap.data.feature.Feature; |
|
12 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
|
13 |
import org.gvsig.fmap.data.feature.FeatureStore; |
|
14 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
15 |
|
|
16 |
|
|
17 |
/** |
|
18 |
* This class extends AbstractLinkProperties and implements the method to get an array of URI |
|
19 |
* using a point2D and a tolerance. This class extends AstractLinkProperties to add HyperLink |
|
20 |
* to Vectorial Layer(FLyrVect) |
|
21 |
*/ |
|
22 |
|
|
23 |
public class FLyrVectLinkProperties extends AbstractLinkProperties{ |
|
24 |
|
|
25 |
/** |
|
26 |
* Default Constructor. Costructs a LinkProperties with the necessary information |
|
27 |
* |
|
28 |
*/ |
|
29 |
public FLyrVectLinkProperties(){ |
|
30 |
setType(0); |
|
31 |
setField(null); |
|
32 |
setExt(null); |
|
33 |
} |
|
34 |
|
|
35 |
/** |
|
36 |
* Constructor. Constructs a LinkProperties with the information that receives |
|
37 |
* @param tipo |
|
38 |
* @param fieldName |
|
39 |
* @param extension |
|
40 |
*/ |
|
41 |
public FLyrVectLinkProperties(int tipo, String fieldName, String extension){ |
|
42 |
setType(tipo); |
|
43 |
setField(fieldName); |
|
44 |
setExt(extension); |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Creates an array of URI. With the point and the tolerance makes a query to the layer |
|
49 |
* and gets the geometries that contains the point with a certain error (tolerance). |
|
50 |
* For each one of this geometries creates one URI and adds it to the array |
|
51 |
* @param layer |
|
52 |
* @param point |
|
53 |
* @param tolerance |
|
54 |
* @return Array of URI |
|
55 |
* @throws ReadException |
|
56 |
*/ |
|
57 |
public URI[] getLink(FLayer layer, Point2D point, double tolerance) throws ReadException{ |
|
58 |
//Sacado de la clase LinkListener |
|
59 |
FLyrVect lyrVect = (FLyrVect) layer; |
|
60 |
FeatureStore fStore = null; |
|
61 |
FeatureCollection fCollection=null; |
|
62 |
|
|
63 |
try { |
|
64 |
fStore = lyrVect.getFeatureStore(); |
|
65 |
URI uri[]=null; |
|
66 |
|
|
67 |
//Construimos el BitSet (V?ctor con componentes BOOLEAN) con la consulta que |
|
68 |
//hacemos a la capa. |
|
69 |
String filter = "true = false"; //FIXME: Funcion!!! |
|
70 |
try { |
|
71 |
fCollection = (FeatureCollection)fStore.getDataCollection(fStore.getDefaultFeatureType(), filter, null); |
|
72 |
} catch (ReadException e) { |
|
73 |
return null; |
|
74 |
} |
|
75 |
|
|
76 |
Iterator iter = null; |
|
77 |
//Si el bitset creado no est? vac?o creamos el vector de URLS correspondientes |
|
78 |
//a la consulta que hemos hecho. |
|
79 |
|
|
80 |
ArrayList tmpUris=new ArrayList(); |
|
81 |
String auxext=""; |
|
82 |
int idField = fStore.getDefaultFeatureType().getFieldIndex(this.getField()); |
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
//Consigo el identificador del campo pasandole como par?metro el |
|
88 |
//nombre del campo del ?nlace |
|
89 |
if (idField == -1){ |
|
90 |
throw new ReadException(lyrVect.getName()+": '"+this.getField()+"' not found",new Exception()); |
|
91 |
} |
|
92 |
//Recorremos el BitSet siguiendo el ejmplo de la clase que se |
|
93 |
//proporciona en la API |
|
94 |
iter = fCollection.iterator(); |
|
95 |
while (iter.hasNext()){ |
|
96 |
//TODO |
|
97 |
//Sacado de la clase LinkPanel, decidir como pintar la URL le |
|
98 |
//corresponde a LinkPanel, aqu? solo creamos el vector de URL?s |
|
99 |
if (!super.getExt().equals("")){ |
|
100 |
auxext="."+this.getExt(); |
|
101 |
} |
|
102 |
// ds.start(); |
|
103 |
//Creamos el fichero con el nombre del campo y la extensi?n. |
|
104 |
Feature feature = (Feature) iter.next(); |
|
105 |
String auxField=feature.getString(idField); |
|
106 |
URI tmpUri = null; |
|
107 |
if(auxField.startsWith("http:/")){ |
|
108 |
tmpUri= new URI(auxField); |
|
109 |
}else{ |
|
110 |
File file =new File(feature.getString(idField)+auxext); |
|
111 |
tmpUri = file.toURI(); |
|
112 |
} |
|
113 |
tmpUris.add(tmpUri); |
|
114 |
System.out.println(tmpUri.toString()); |
|
115 |
//System.out.println(uri[j]); |
|
116 |
|
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
if (tmpUris.size()==0){ |
|
121 |
return null; |
|
122 |
} |
|
123 |
|
|
124 |
//Creo el vector de URL?s con la misma longitud que el bitset |
|
125 |
uri = new URI[tmpUris.size()]; |
|
126 |
iter = tmpUris.iterator(); |
|
127 |
int i=0; |
|
128 |
while (iter.hasNext()){ |
|
129 |
uri[i]=(URI) iter.next(); |
|
130 |
i++; |
|
131 |
} |
|
132 |
|
|
133 |
return uri; |
|
134 |
|
|
135 |
} catch (ReadException e) { |
|
136 |
throw new ReadException(lyrVect.getName(),e); |
|
137 |
} catch (URISyntaxException e) { |
|
138 |
throw new ReadException(lyrVect.getName(),e); |
|
139 |
}finally{ |
|
140 |
fCollection.dispose(); |
|
141 |
} |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
public String getClassName() { |
|
146 |
// TODO Auto-generated method stub |
|
147 |
return null; |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
} |
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVectLinkProperties.java | ||
---|---|---|
1 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
|
2 |
|
|
3 |
import java.awt.geom.Point2D; |
|
4 |
import java.io.File; |
|
5 |
import java.net.URI; |
|
6 |
import java.net.URISyntaxException; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.Iterator; |
|
9 |
|
|
10 |
import org.gvsig.fmap.data.ReadException; |
|
11 |
import org.gvsig.fmap.data.feature.Feature; |
|
12 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
|
13 |
import org.gvsig.fmap.data.feature.FeatureStore; |
|
14 |
import org.gvsig.fmap.mapcontext.layers.AbstractLinkProperties; |
|
15 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
16 |
|
|
17 |
|
|
18 |
/** |
|
19 |
* This class extends AbstractLinkProperties and implements the method to get an array of URI |
|
20 |
* using a point2D and a tolerance. This class extends AstractLinkProperties to add HyperLink |
|
21 |
* to Vectorial Layer(FLyrVect) |
|
22 |
*/ |
|
23 |
|
|
24 |
public class FLyrVectLinkProperties extends AbstractLinkProperties{ |
|
25 |
|
|
26 |
/** |
|
27 |
* Default Constructor. Costructs a LinkProperties with the necessary information |
|
28 |
* |
|
29 |
*/ |
|
30 |
public FLyrVectLinkProperties(){ |
|
31 |
setType(0); |
|
32 |
setField(null); |
|
33 |
setExt(null); |
|
34 |
} |
|
35 |
|
|
36 |
/** |
|
37 |
* Constructor. Constructs a LinkProperties with the information that receives |
|
38 |
* @param tipo |
|
39 |
* @param fieldName |
|
40 |
* @param extension |
|
41 |
*/ |
|
42 |
public FLyrVectLinkProperties(int tipo, String fieldName, String extension){ |
|
43 |
setType(tipo); |
|
44 |
setField(fieldName); |
|
45 |
setExt(extension); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Creates an array of URI. With the point and the tolerance makes a query to the layer |
|
50 |
* and gets the geometries that contains the point with a certain error (tolerance). |
|
51 |
* For each one of this geometries creates one URI and adds it to the array |
|
52 |
* @param layer |
|
53 |
* @param point |
|
54 |
* @param tolerance |
|
55 |
* @return Array of URI |
|
56 |
* @throws ReadException |
|
57 |
*/ |
|
58 |
public URI[] getLink(FLayer layer, Point2D point, double tolerance) throws ReadException{ |
|
59 |
//Sacado de la clase LinkListener |
|
60 |
FLyrVect lyrVect = (FLyrVect) layer; |
|
61 |
FeatureStore fStore = null; |
|
62 |
FeatureCollection fCollection=null; |
|
63 |
|
|
64 |
try { |
|
65 |
fStore = lyrVect.getFeatureStore(); |
|
66 |
URI uri[]=null; |
|
67 |
|
|
68 |
//Construimos el BitSet (V?ctor con componentes BOOLEAN) con la consulta que |
|
69 |
//hacemos a la capa. |
|
70 |
String filter = "true = false"; //FIXME: Funcion!!! |
|
71 |
try { |
|
72 |
fCollection = (FeatureCollection)fStore.getDataCollection(fStore.getDefaultFeatureType(), filter, null); |
|
73 |
} catch (ReadException e) { |
|
74 |
return null; |
|
75 |
} |
|
76 |
|
|
77 |
Iterator iter = null; |
|
78 |
//Si el bitset creado no est? vac?o creamos el vector de URLS correspondientes |
|
79 |
//a la consulta que hemos hecho. |
|
80 |
|
|
81 |
ArrayList tmpUris=new ArrayList(); |
|
82 |
String auxext=""; |
|
83 |
int idField = fStore.getDefaultFeatureType().getFieldIndex(this.getField()); |
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
//Consigo el identificador del campo pasandole como par?metro el |
|
89 |
//nombre del campo del ?nlace |
|
90 |
if (idField == -1){ |
|
91 |
throw new ReadException(lyrVect.getName()+": '"+this.getField()+"' not found",new Exception()); |
|
92 |
} |
|
93 |
//Recorremos el BitSet siguiendo el ejmplo de la clase que se |
|
94 |
//proporciona en la API |
|
95 |
iter = fCollection.iterator(); |
|
96 |
while (iter.hasNext()){ |
|
97 |
//TODO |
|
98 |
//Sacado de la clase LinkPanel, decidir como pintar la URL le |
|
99 |
//corresponde a LinkPanel, aqu? solo creamos el vector de URL?s |
|
100 |
if (!super.getExt().equals("")){ |
|
101 |
auxext="."+this.getExt(); |
|
102 |
} |
|
103 |
// ds.start(); |
|
104 |
//Creamos el fichero con el nombre del campo y la extensi?n. |
|
105 |
Feature feature = (Feature) iter.next(); |
|
106 |
String auxField=feature.getString(idField); |
|
107 |
URI tmpUri = null; |
|
108 |
if(auxField.startsWith("http:/")){ |
|
109 |
tmpUri= new URI(auxField); |
|
110 |
}else{ |
|
111 |
File file =new File(feature.getString(idField)+auxext); |
|
112 |
tmpUri = file.toURI(); |
|
113 |
} |
|
114 |
tmpUris.add(tmpUri); |
|
115 |
System.out.println(tmpUri.toString()); |
|
116 |
//System.out.println(uri[j]); |
|
117 |
|
|
118 |
|
|
119 |
} |
|
120 |
|
|
121 |
if (tmpUris.size()==0){ |
|
122 |
return null; |
|
123 |
} |
|
124 |
|
|
125 |
//Creo el vector de URL?s con la misma longitud que el bitset |
|
126 |
uri = new URI[tmpUris.size()]; |
|
127 |
iter = tmpUris.iterator(); |
|
128 |
int i=0; |
|
129 |
while (iter.hasNext()){ |
|
130 |
uri[i]=(URI) iter.next(); |
|
131 |
i++; |
|
132 |
} |
|
133 |
|
|
134 |
return uri; |
|
135 |
|
|
136 |
} catch (ReadException e) { |
|
137 |
throw new ReadException(lyrVect.getName(),e); |
|
138 |
} catch (URISyntaxException e) { |
|
139 |
throw new ReadException(lyrVect.getName(),e); |
|
140 |
}finally{ |
|
141 |
fCollection.dispose(); |
|
142 |
} |
|
143 |
|
|
144 |
} |
|
145 |
|
|
146 |
public String getClassName() { |
|
147 |
// TODO Auto-generated method stub |
|
148 |
return null; |
|
149 |
} |
|
150 |
|
|
151 |
|
|
152 |
} |
branches/v2_0_0_prep/libraries/libFMap_mapcontext/src/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java | ||
---|---|---|
82 | 82 |
import org.gvsig.fmap.mapcontext.layers.AbstractLinkProperties; |
83 | 83 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
84 | 84 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
85 |
import org.gvsig.fmap.mapcontext.layers.FLyrVectLinkProperties; |
|
86 | 85 |
import org.gvsig.fmap.mapcontext.layers.LayerEvent; |
87 | 86 |
import org.gvsig.fmap.mapcontext.layers.SpatialCache; |
88 | 87 |
import org.gvsig.fmap.mapcontext.layers.XMLException; |
... | ... | |
1886 | 1885 |
return (FeatureStore)getDataStore(); |
1887 | 1886 |
} |
1888 | 1887 |
|
1889 |
public FeatureCollection queryByPoint(Point2D mapPoint, double tol) throws ReadException { |
|
1888 |
public FeatureCollection queryByPoint(Point2D mapPoint, double tol, FeatureType featureType) throws ReadException {
|
|
1890 | 1889 |
// double halfTol=tol*0.5; |
1891 | 1890 |
// Envelope envelope=new DefaultEnvelope(mapPoint.getX()-halfTol,mapPoint.getY()-halfTol,mapPoint.getX()+halfTol,mapPoint.getY()+halfTol); |
1892 | 1891 |
// return queryByEnvelope(envelope); |
1893 | 1892 |
Geometry geom = GeometryManager.getInstance().getGeometryFactory() |
1894 | 1893 |
.createCircle(mapPoint, tol); |
1895 | 1894 |
|
1896 |
return queryByGeometry(geom); |
|
1895 |
return queryByGeometry(geom, featureType);
|
|
1897 | 1896 |
} |
1898 | 1897 |
|
1899 | 1898 |
|
1900 |
public FeatureCollection queryByGeometry(Geometry geom) throws ReadException { |
|
1899 |
public FeatureCollection queryByGeometry(Geometry geom, FeatureType featureType) throws ReadException {
|
|
1901 | 1900 |
try { |
1902 | 1901 |
return (FeatureCollection) |
1903 | 1902 |
getFeatureStore().getDataCollection( |
1904 |
getFeatureStore().getDefaultFeatureType(),
|
|
1903 |
featureType,
|
|
1905 | 1904 |
getDataStoreFilterForGeomerty( |
1906 | 1905 |
geom, |
1907 |
getFeatureStore().getDefaultFeatureType().getDefaultGeometry(),
|
|
1906 |
featureType.getDefaultGeometry(),
|
|
1908 | 1907 |
null), |
1909 | 1908 |
null); |
1910 | 1909 |
} catch (GeometryOperationNotSupportedException e) { |
... | ... | |
1939 | 1938 |
+ "), " + geomFileName + ") "; |
1940 | 1939 |
} |
1941 | 1940 |
|
1942 |
public FeatureCollection queryByEnvelope(Envelope rect) |
|
1941 |
public FeatureCollection queryByEnvelope(Envelope rect, FeatureType featureType)
|
|
1943 | 1942 |
throws ReadException { |
1944 |
return this.queryByGeometry(rect.getGeometry()); |
|
1943 |
return this.queryByGeometry(rect.getGeometry(),featureType);
|
|
1945 | 1944 |
} |
1946 | 1945 |
|
1947 | 1946 |
public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancel) throws ReadException, LoadLayerException { |
1948 | 1947 |
Point2D pReal = this.getMapContext().getViewPort().toMapPoint(p); |
1949 |
FeatureCollection featureCollection = queryByPoint(pReal, tolerance); |
|
1948 |
FeatureCollection featureCollection = queryByPoint(pReal, tolerance, getFeatureStore().getDefaultFeatureType());
|
|
1950 | 1949 |
VectorialXMLItem[] item = new VectorialXMLItem[1]; |
1951 | 1950 |
item[0] = new VectorialXMLItem(featureCollection, this); |
1952 | 1951 |
|
Also available in: Unified diff