Revision 212

View differences:

org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.busquedacatastral.lib.api.BusquedaCatastralLibrary
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/BusquedaCatastralManager.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api;
24

  
25
import java.io.File;
26
import java.io.IOException;
27
import java.util.List;
28

  
29
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingDataException;
30
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
31
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidSRSException;
32
import org.gvsig.fmap.geom.primitive.Point;
33
import org.gvsig.tools.dynobject.DynObject;
34

  
35
/**
36
 * This class is responsible of the management of the library's business logic.
37
 * It is the library's main entry point, and provides all the services to manage
38
 * {@link WebMapService}s.
39
 *
40
 * @see WebMapService
41
 * @author gvSIG team
42
 * @version $Id$
43
 */
44
public interface BusquedaCatastralManager {
45

  
46
       //Provincia
47
       public static final String CAMPO_PROVINCIA_NOMBRE="np";
48
       public static final String CAMPO_PROVINCIA_ETIQUETA="np";
49
       public static final String CAMPO_PROVINCIA_CODIGO="cpine";
50
       //Municipio
51
       public static final String CAMPO_MUNICIPIO_NOMBRE="nm";
52
       public static final String CAMPO_MUNICIPIO_ETIQUETA="nm";
53
       public static final String CAMPO_MUNICIPIO_DELEGACION_MEH="locat_cd";
54
       public static final String CAMPO_MUNICIPIO_CODIGO_MEH="locat_cmc";
55
       public static final String CAMPO_MUNICIPIO_PROVINCIA_INE="loine_cp";
56
       public static final String CAMPO_MUNICIPIO_MUNICIPIO_INE="loine_cm";
57

  
58
       //Via
59
       public static final String CAMPO_VIA_NOMBRE="dir_nv";
60
       public static final String CAMPO_VIA_ETIQUETA="dir_nv";
61
       public static final String CAMPO_VIA_TIPOVIA="dir_tp";
62
       public static final String CAMPO_VIA_COD_DGC="dir_cv";
63
       public static final String CAMPO_VIA_PROV_INE="loine_cp";
64
       public static final String CAMPO_VIA_MUNI_INE="loine_cm";
65

  
66

  
67
       /**
68
        * deletes cache
69
        */
70
       public void deleteCache() throws IOException;
71

  
72
       /**
73
        * Creates a query object to get data from catastro
74
        * @return QueryCatastral
75
        */
76
       public QueryCatastral createQuery();
77

  
78
       /**
79
        * Gets Provincias from catastro
80
        * @return List<DynObject>
81
        */
82
       public List<DynObject> getProvincias() throws BusquedaCatastralGettingParamsException;
83

  
84
       /**
85
        * Gets Municipios from catastro, depending from provincia
86
        * @param query
87
        * @return List<DynObject>
88
        */
89
       public List<DynObject> getMunicipios(QueryCatastral query) throws BusquedaCatastralGettingParamsException;
90

  
91
       /**
92
        * Gets Municipios from catastro, depending from provincia and filtered
93
        * @param query
94
        * @param municipio
95
        * @return List<DynObject>
96
        */
97
       public List<DynObject> getMunicipios(QueryCatastral query, String municipio)throws BusquedaCatastralGettingParamsException;
98

  
99
       /**
100
        * Tipos de vias del catastro
101
        * @return List<TipoVia>
102
        */
103
       public List<TipoVia> getTiposDeVia()throws BusquedaCatastralGettingParamsException;
104

  
105
       /**
106
        * Vias del catastro en funcion del municipio
107
        * @param query
108
        * @return List<DynObject>
109
        */
110
       public List<DynObject> getVias(QueryCatastral query)throws BusquedaCatastralGettingParamsException;
111

  
112
       /**
113
        * Vias del catastro en funcion del municipio, filtrado
114
        * @param query
115
        * @param via
116
        * @return List<DynObject>
117
        */
118
       public List<DynObject> getVias(QueryCatastral query, String via)throws BusquedaCatastralGettingParamsException;
119

  
120
       /**
121
        * Devuelve los posibles numeros de una v?a entre un intervalo dado
122
        * @param query
123
        * @param inicio
124
        * @param fin
125
        * @return List<String>
126
        */
127
       public List<String> getNumeros(QueryCatastral query,String inicio, String fin)throws BusquedaCatastralGettingParamsException;
128

  
129
       /**
130
        * Devuelve las referecias catastrales para la query formada
131
        * @param query
132
        * @return List<ReferenciaCatastral>
133
        */
134
       public List<ReferenciaCatastral> getReferenciasCatastrales(QueryCatastral query)throws BusquedaCatastralGettingParamsException;
135

  
136
       /**
137
        * Devuelve un punto del centroide correspondiente de la referencia catastral
138
        * @param referenciacatastral
139
        * @return Point
140
        */
141
       public Point getPoint(String referenciacatastral, SRSCatastro srs)throws BusquedaCatastralGettingDataException, BusquedaCatastralInvalidSRSException;
142

  
143
       /**
144
        * Devuelve un punto del centroide correspondiente del codigo de la referencia catastral
145
        * @param referenciacatastral
146
        * @return Point
147
        */
148
       public Point getPoint(ReferenciaCatastral referenciacatastral, SRSCatastro srs)throws BusquedaCatastralGettingDataException, BusquedaCatastralInvalidSRSException;
149

  
150
       /**
151
        * Devuelve los datos catastrales de la parcela en el punto indicado
152
        * @param p
153
        * @return DynObject
154
        */
155
       public DynObject getDatosCatastrales(Point p, SRSCatastro srs)throws BusquedaCatastralGettingDataException, BusquedaCatastralInvalidSRSException;
156

  
157
       /**
158
        * Devuelve los datos catastrales del codigo de la referencia catastral
159
        * @param rc
160
        * @return DynObject
161
        */
162
       public DynObject getDatosCatastrales(String rc)throws BusquedaCatastralGettingDataException;
163

  
164
       public File getCacheFolder();
165

  
166
       public void setCacheFolder(File cacheFolder);
167
}
168

  
169

  
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/QueryCatastral.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidQueryException;
4
import org.gvsig.tools.dynobject.DynObject;
5

  
6
/**
7
 * Params to query catastro
8
 * @author dmartinezizquierdo
9
 *
10
 */
11
public interface QueryCatastral {
12

  
13
    enum TipoParcela{URBANA,RUSTICA};
14

  
15
    enum TipoQuery{POR_RC,POR_LOCALIZACION};
16

  
17
    public TipoQuery getTipoQuery();
18

  
19
    public void setTipoQuery(TipoQuery tipoQuery);
20

  
21
    public TipoParcela getTipoParcela();
22

  
23
    public void setReferenciaCatastral(String referenciaCatastral);
24

  
25
    public String getReferenciaCatastral();
26

  
27
    public void setTipoParcela(TipoParcela tipoParcela);
28

  
29
    public DynObject getProvincia();
30

  
31
    public void setProvincia(DynObject provincia);
32

  
33
    public DynObject getMunicipio();
34

  
35
    public void setMunicipio(DynObject municipio);
36

  
37
    public TipoVia getTipoVia();
38

  
39
    public void setTipoVia(TipoVia tipoVia);
40

  
41
    public DynObject getVia();
42

  
43
    public void setVia(DynObject via);
44

  
45
    public String getNumero();
46

  
47
    public void setNumero (String numero);
48

  
49
    public String getBloque ();
50

  
51
    public void setBloque (String bloque);
52

  
53
    public String getEscalera ();
54

  
55
    public void setEscalera (String escalera);
56

  
57
    public String getPlanta ();
58

  
59
    public void setPlanta (String planta);
60

  
61
    public String getPuerta ();
62

  
63
    public void setPuerta (String puerta);
64

  
65
    public String getPoligono();
66

  
67
    public void setPoligono (String poligono);
68

  
69
    public String getParcela ();
70

  
71
    public void setParcela (String parcela);
72

  
73
    public void validateQuery() throws BusquedaCatastralInvalidQueryException;
74
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/SRSCatastro.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3
import org.gvsig.tools.ToolsLocator;
4

  
5
/**
6
 * Enumeracion con los SRS aceptados por Catastro
7
 * @author dmartinezizquierdo
8
 *
9
 */
10
public enum SRSCatastro {
11
    EPSG_4230("EPSG:4230","Geogr?ficas en ED 50"),
12
    EPSG_4326("EPSG:4326","Geogr?ficas en WGS 80",true),//default
13
    EPSG_4258("EPSG:4258","Geogr?ficas en ETRS89"),
14
    EPSG_32627("EPSG:32627","UTM huso 27N en WGS 84"),
15
    EPSG_32628("EPSG:32628","UTM huso 28N en WGS 84"),
16
    EPSG_32629("EPSG:32629","UTM huso 29N en WGS 84"),
17
    EPSG_32630("EPSG:32630","UTM huso 30N en WGS 84"),
18
    EPSG_32631("EPSG:32631","UTM huso 31N en WGS 84"),
19
    EPSG_25829("EPSG:25829","UTM huso 29N en ETRS89"),
20
    EPSG_25830("EPSG:25830","UTM huso 30N en ETRS89"),
21
    EPSG_25831("EPSG:25831","UTM huso 31N en ETRS89"),
22
    EPSG_23029("EPSG:23029","UTM huso 29N en ED50"),
23
    EPSG_23030("EPSG:23030","UTM huso 30N en ED50"),
24
    EPSG_23031("EPSG:23031","UTM huso 31N en ED50");
25

  
26

  
27
    private final String cod;
28
    private final String label;
29
    private final boolean isDefault;
30

  
31
    SRSCatastro(String cod, String label, boolean isDefault){
32
        this.cod = cod;
33
        this.label = label;
34
        this.isDefault=isDefault;
35
    }
36

  
37
    SRSCatastro(String cod, String label){
38
        this.cod = cod;
39
        this.label = label;
40
        this.isDefault=false;
41
    }
42

  
43
    /**
44
     * Gets SRS codigo
45
     * @return String
46
     */
47
    public String getCod(){
48
        return this.cod;
49
    }
50

  
51
    /**
52
     * Gets SRS label
53
     * @return String
54
     */
55
    public String getLabel(){
56
        return this.label;
57
    }
58

  
59
    /**
60
     * gets the default SRS for Catastro
61
     * @return
62
     */
63
    public static SRSCatastro getDefaultSRS(){
64
        for (SRSCatastro srs:SRSCatastro.values()){
65
            if(srs.isDefault){
66
                return srs;
67
            }
68
        }
69
        return null;
70
    }
71

  
72
    /**
73
     * gets the default SRS for Catastro
74
     * @return
75
     */
76
    public static SRSCatastro getCatastroByCod(String cod){
77
        for (SRSCatastro srs:SRSCatastro.values()){
78
            if(srs.getCod().equals(cod)){
79
                return srs;
80
            }
81
        }
82
        return null;
83
    }
84
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/TipoVia.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3
import org.gvsig.tools.ToolsLocator;
4

  
5
/**
6
 * Enumeracion con los tipos de vias
7
 * @author dmartinezizquierdo
8
 *
9
 */
10
public enum TipoVia {
11
    BLANK("","-----"),
12
    ACCESO("AC","ACCESO"),
13
    AGREGADO("AG","AGREGADO"),
14
    ALDEA_ALAMEDA("AL","ALDEA, ALAMEDA"),
15
    ANDADOR("AN","ANDADOR"),
16
    AREA_ARRABAL("AR","AREA, ARRABAL"),
17
    AUTOPISTA("AU","AUTOPISTA"),
18
    AVENIDA("AV","AVENIDA"),
19
    ARROYO("AY","ARROYO"),
20
    BAJADA("BJ","BAJADA"),
21
    BLOQUE("BL","BLOQUE"),
22
    BARRIO("BO","BARRIO"),
23
    BARRANQUIL("BQ","BARRANQUIL"),
24
    BARRANCO("BR","BARRANCO"),
25
    CA?ADA("CA","CA?ADA"),
26
    COLEGIO_CIGARRAL("CG","COLEGIO, CIGARRAL"),
27
    CHALET("CH","CHALET"),
28
    CINTURON("CI","CINTURON"),
29
    CALLEJA_CALLEJON("CJ","CALLEJA, CALLEJON"),
30
    CALLE("CL","CALLE"),
31
    CAMINO_CARMEN("CM","CAMINO, CARMEN"),
32
    COLONIA("CN","COLONIA"),
33
    CONCEJO_COLEGIO("CO","CONCEJO, COLEGIO"),
34
    CAMPA_CAMPO("CP","CAMPA, CAMPO"),
35
    CARRETERA_CARRERA("CR","CARRETERA, CARRERA"),
36
    CASERIO("CS","CASERIO"),
37
    CUESTA_COSTANILLA("CT","CUESTA, COSTANILLA"),
38
    CONJUNTO("CU","CONJUNTO"),
39
    CALEYA("CY","CALEYA"),
40
    CALLIZO("CZ","CALLIZO"),
41
    DETR?S("DE","DETR?S"),
42
    DIPUTACION("DP","DIPUTACION"),
43
    DISEMINADOS("DS","DISEMINADOS"),
44
    EDIFICIOS("ED","EDIFICIOS"),
45
    EXTRAMUROS("EM","EXTRAMUROS"),
46
    ENTRADA_ENSANCHE("EN","ENTRADA, ENSANCHE"),
47
    ESPALDA("EP","ESPALDA"),
48
    EXTRARRADIO("ER","EXTRARRADIO"),
49
    ESCALINATA("ES","ESCALINATA"),
50
    EXPLANADA("EX","EXPLANADA"),
51
    FERROCARRIL("FC","FERROCARRIL"),
52
    FINCA("FN","FINCA"),
53
    GLORIETA("GL","GLORIETA"),
54
    GRUPO("GR","GRUPO"),
55
    GRAN_VIA("GV","GRAN VIA"),
56
    HUERTA_HUERTO("HT","HUERTA, HUERTO"),
57
    JARDINES("JR","JARDINES"),
58
    LAGO("LA","LAGO"),
59
    LADO_LADERA("LD","LADO, LADERA"),
60
    LUGAR("LG","LUGAR"),
61
    MALECON("MA","MALECON"),
62
    MERCADO("MC","MERCADO"),
63
    MUELLE("ML","MUELLE"),
64
    MUNICIPIO("MN","MUNICIPIO"),
65
    MASIAS("MS","MASIAS"),
66
    MONTE("MT","MONTE"),
67
    MANZANA("MZ","MANZANA"),
68
    POBLADO("PB","POBLADO"),
69
    PLACETA("PC","PLACETA"),
70
    PARTIDA("PD","PARTIDA"),
71
    PARTICULAR("PI","PARTICULAR"),
72
    PASAJE_PASADIZO("PJ","PASAJE, PASADIZO"),
73
    POLIGONO("PL","POLIGONO"),
74
    PARAMO("PM","PARAMO"),
75
    PARROQUIA_PARQUE("PQ","PARROQUIA, PARQUE"),
76
    PROLONGACION_CONTINUAC("PR","PROLONGACION, CONTINUAC."),
77
    PASEO("PS","PASEO"),
78
    PUENTE("PT","PUENTE"),
79
    PASADIZO("PU","PASADIZO"),
80
    PLAZA("PZ","PLAZA"),
81
    QUINTA("QT","QUINTA"),
82
    RACONADA("RA","RACONADA"),
83
    RAMBLA("RB","RAMBLA"),
84
    RINCON_RINCONA("RC","RINCON, RINCONA"),
85
    RONDA("RD","RONDA"),
86
    RAMAL("RM","RAMAL"),
87
    RAMPA("RP","RAMPA"),
88
    RIERA("RR","RIERA"),
89
    RUA("RU","RUA"),
90
    SALIDA("SA","SALIDA"),
91
    SECTOR("SC","SECTOR"),
92
    SENDA("SD","SENDA"),
93
    SOLAR("SL","SOLAR"),
94
    SALON("SN","SALON"),
95
    SUBIDA("SU","SUBIDA"),
96
    TERRENOS("TN","TERRENOS"),
97
    TORRENTE("TO","TORRENTE"),
98
    TRAVESIA("TR","TRAVESIA"),
99
    URBANIZACION("UR","URBANIZACION"),
100
    VALLE("VA","VALLE"),
101
    VIADUCTO("VD","VIADUCTO"),
102
    VIA("VI","VIA"),
103
    VIAL("VL","VIAL"),
104
    VEREDA("VR","VEREDA");
105

  
106

  
107
    private final String abrev;
108
    private final String label;
109

  
110
    TipoVia(String abrev, String label){
111
        this.abrev = abrev;
112
        this.label = label;
113
    }
114

  
115
    /**
116
     * Gets Tipo via codigo
117
     * @return String
118
     */
119
    public String getAbrev(){
120
        return this.abrev;
121
    }
122

  
123
    /**
124
     * Gets Tipo via label
125
     * @return String
126
     */
127
    public String getLabel(){
128
        return this.label;
129
    }
130

  
131
    /**
132
     * gets the tipoVia for the given cod
133
     * @return
134
     */
135
    public static TipoVia getTipoViaByAbrev(String abrev){
136
        for (TipoVia tipoVia:TipoVia.values()){
137
            if(tipoVia.getAbrev().equals(abrev)){
138
                return tipoVia;
139
            }
140
        }
141
        return null;
142
    }
143
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/BusquedaCatastralLocator.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api;
24

  
25
import org.gvsig.tools.locator.BaseLocator;
26
import org.gvsig.tools.locator.Locator;
27
import org.gvsig.tools.locator.LocatorException;
28

  
29
/**
30
 * This locator is the entry point for the BusquedaCatastral library,
31
 * providing access to all services through the
32
 * {@link BusquedaCatastralManager} .
33
 *
34
 * @author gvSIG team
35
 * @version $Id$
36
 */
37
public class BusquedaCatastralLocator extends BaseLocator {
38

  
39
    private static final String LOCATOR_NAME = "BusquedaCatastral.locator";
40

  
41
    /**
42
     * WebMap manager name.
43
     */
44
    public static final String MANAGER_NAME = "BusquedaCatastral.manager";
45

  
46
    /**
47
     * WebMap manager description.
48
     */
49
    public static final String MANAGER_DESCRIPTION = "BusquedaCatastral Manager";
50

  
51

  
52
    /**
53
     * Unique instance.
54
     */
55
    private static final BusquedaCatastralLocator INSTANCE =
56
        new BusquedaCatastralLocator();
57

  
58
    /**
59
     * Return the singleton instance.
60
     *
61
     * @return the singleton instance
62
     */
63
    public static BusquedaCatastralLocator getInstance() {
64
        return INSTANCE;
65
    }
66

  
67
    /**
68
     * Return the Locator's name.
69
     *
70
     * @return a String with the Locator's name
71
     */
72
    public final String getLocatorName() {
73
        return LOCATOR_NAME;
74
    }
75

  
76
    /**
77
     * Return a reference to the Manager.
78
     *
79
     * @return a reference to the Manager
80
     * @throws LocatorException
81
     *             if there is no access to the class or the class cannot be
82
     *             instantiated
83
     * @see Locator#get(String)
84
     */
85
    public static BusquedaCatastralManager getManager() throws LocatorException {
86
        return (BusquedaCatastralManager) getInstance().get(MANAGER_NAME);
87
    }
88

  
89
    /**
90
     * Registers the Class implementing the WebMapManager interface.
91
     *
92
     * @param clazz
93
     *            implementing the WebMapManager interface
94
     */
95
    public static void registerManager(
96
        Class<? extends BusquedaCatastralManager> clazz) {
97
        getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz);
98
    }
99

  
100
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/BusquedaCatastralLibrary.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api;
24

  
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
28

  
29
/**
30
 * Library for search by catastral data initialization and configuration.
31
 *
32
 * @author gvSIG team
33
 * @version $Id$
34
 */
35
public class BusquedaCatastralLibrary extends AbstractLibrary {
36

  
37
    @Override
38
    public void doRegistration() {
39
        registerAsAPI(BusquedaCatastralLibrary.class);
40
    }
41

  
42
    @Override
43
    protected void doInitialize() throws LibraryException {
44
        // Do nothing
45
    }
46

  
47
    @Override
48
    protected void doPostInitialize() throws LibraryException {
49
        // Validate there is any implementation registered.
50
        BusquedaCatastralManager manager = BusquedaCatastralLocator.getManager();
51
        if (manager == null) {
52
            throw new ReferenceNotRegisteredException(
53
                BusquedaCatastralLocator.MANAGER_NAME, BusquedaCatastralLocator.getInstance());
54
        }
55
    }
56

  
57
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralGettingDataException.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api.exceptions;
24

  
25
public class BusquedaCatastralGettingDataException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "An error has been produced getting busqueda catastral data.";
35

  
36
    private static final String KEY = "_BusquedaCatastralGettingDataException";
37

  
38
    public BusquedaCatastralGettingDataException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralGettingDataException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralInvalidQueryException.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api.exceptions;
24

  
25
public class BusquedaCatastralInvalidQueryException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "Invalid query for busqueda catastral";
35

  
36
    private static final String KEY = "_BusquedaCatastralInvalidQueryException";
37

  
38
    public BusquedaCatastralInvalidQueryException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralInvalidQueryException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralInvalidSRSException.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api.exceptions;
24

  
25
public class BusquedaCatastralInvalidSRSException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "An error has been produced using an invalid SRS for Busqueda Catastral.";
35

  
36
    private static final String KEY = "_BusquedaCatastralInvalidSRSException";
37

  
38
    public BusquedaCatastralInvalidSRSException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralInvalidSRSException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralException.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api.exceptions;
24

  
25

  
26
import org.gvsig.tools.exception.BaseException;
27

  
28
/**
29
 *
30
 * @author gvSIG team.
31
 *
32
 */
33
public class BusquedaCatastralException extends BaseException {
34

  
35
    /**
36
     *
37
     */
38
    private static final long serialVersionUID = -1043709801185809443L;
39

  
40
    private static final String MESSAGE =
41
        "An error has been produced in the Busqueda Catastral library";
42

  
43
    private static final String KEY = "_WasteException";
44

  
45
    /**
46
     * Constructor to be used in rare cases, usually you must create a new child
47
     * exception class for each case.
48
     * <strong>Don't use this constructor in child classes.</strong>
49
     */
50
    public BusquedaCatastralException() {
51
        super(MESSAGE, KEY, serialVersionUID);
52
    }
53

  
54
    /**
55
     * Constructor to be used in rare cases, usually you must create a new child
56
     * exception class for each case.
57
     * <p>
58
     * <strong>Don't use this constructor in child classes.</strong>
59
     * </p>
60
     *
61
     * @param cause
62
     *            the original cause of the exception
63
     */
64
    public BusquedaCatastralException(Exception cause) {
65
        super(MESSAGE, cause, KEY, serialVersionUID);
66
    }
67

  
68
    /**
69
     * @see BaseException#BaseException(String, String, long).
70
     * @param message
71
     *            the default messageFormat to describe the exception
72
     * @param key
73
     *            the key to use to search a localized messageFormnata
74
     * @param code
75
     *            the unique code to identify the exception
76
     */
77
    protected BusquedaCatastralException(String message, String key, long code) {
78
        super(message, key, code);
79
    }
80

  
81
    /**
82
     * @see BaseException#BaseException(String, Throwable, String, long).
83
     * @param message
84
     *            the default messageFormat to describe the exception
85
     * @param cause
86
     *            the original cause of the exception
87
     * @param key
88
     *            the key to use to search a localized messageFormnata
89
     * @param code
90
     *            the unique code to identify the exception
91
     */
92
    protected BusquedaCatastralException(String message, Throwable cause,
93
        String key, long code) {
94
        super(message, cause, key, code);
95
    }
96

  
97
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralGettingParamsException.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.api.exceptions;
24

  
25
public class BusquedaCatastralGettingParamsException extends BusquedaCatastralException {
26

  
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = 8201868527295813900L;
32

  
33
    private static final String MESSAGE =
34
        "An error has been produced getting busqueda catastral parameters.";
35

  
36
    private static final String KEY = "_BusquedaCatastralGettingParametersException";
37

  
38
    public BusquedaCatastralGettingParamsException(Throwable ex) {
39
        super(MESSAGE, ex, KEY, serialVersionUID);
40
    }
41

  
42
    public BusquedaCatastralGettingParamsException(String message, Throwable ex) {
43
        super(message, ex, KEY, serialVersionUID);
44
    }
45

  
46
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/ReferenciaCatastral.java
1
package org.gvsig.busquedacatastral.lib.api;
2

  
3

  
4
public interface ReferenciaCatastral {
5

  
6
    /**
7
     * Gets el codigo de la referencia catastral
8
     * @return
9
     */
10
    public String getRC();
11

  
12

  
13
    /**
14
     * Gets el codigo de la referencia catastral parcial
15
     * (Positions 1-14)
16
     * @return
17
     */
18
    public String getRCParcial();
19

  
20
    /**
21
     * Gets la localizaci?n (bloque/escalera/planta/puerta)
22
     * @return
23
     */
24
    public String getLocalizacion();
25
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
 <modelVersion>4.0.0</modelVersion>
3
 <parent>
4
  <groupId>org.gvsig</groupId>
5
  <artifactId>org.gvsig.busquedacatastral.lib</artifactId>
6
  <version>1.0.3</version>
7
 </parent>
8

  
9

  
10
 <artifactId>org.gvsig.busquedacatastral.lib.api</artifactId>
11
 <name>${project.artifactId}</name>
12
 <description>API Library for busqueda catastral in gvSIG 2.1</description>
13

  
14
 <build>
15
  <plugins>
16
   <plugin>
17
    <groupId>org.apache.maven.plugins</groupId>
18
    <artifactId>maven-jar-plugin</artifactId>
19
    <configuration>
20
    </configuration>
21
    <executions>
22
     <!-- Generates a jar file only with the test classes -->
23
     <execution>
24
      <goals>
25
       <goal>test-jar</goal>
26
      </goals>
27
     </execution>
28
    </executions>
29
   </plugin>
30
  </plugins>
31
 </build>
32

  
33
 <dependencies>
34
  <dependency>
35
   <groupId>org.gvsig</groupId>
36
   <artifactId>org.gvsig.tools.lib</artifactId>
37
   <scope>compile</scope>
38
  </dependency>
39
    <dependency>
40
   <groupId>org.gvsig</groupId>
41
   <artifactId>org.gvsig.fmap.geometry.api</artifactId>
42
   <scope>compile</scope>
43
  </dependency>
44

  
45
 </dependencies>
46
</project>
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.busquedacatastral</artifactId>
6
    <version>1.0.3</version>
7
  </parent>
8
  <artifactId>org.gvsig.busquedacatastral.lib</artifactId>
9
  <packaging>pom</packaging>
10
  <name>org.gvsig.busquedacatastral.lib</name>
11
  <modules>
12
   <module>org.gvsig.busquedacatastral.lib.api</module>
13
   <module>org.gvsig.busquedacatastral.lib.impl</module>
14
  </modules>
15
</project>
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.busquedacatastral.lib.impl.DefaultBusquedaCatastralLibrary
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/NumerosFactory.java
1
package org.gvsig.busquedacatastral.lib.impl;
2

  
3
import java.io.ByteArrayInputStream;
4
import java.io.File;
5
import java.io.InputStream;
6
import java.rmi.RemoteException;
7
import java.util.ArrayList;
8
import java.util.HashSet;
9
import java.util.List;
10
import java.util.Set;
11

  
12
import javax.xml.bind.JAXBContext;
13
import javax.xml.bind.Unmarshaller;
14

  
15
import org.apache.axis.message.MessageElement;
16
import org.apache.commons.lang3.StringUtils;
17
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralManager;
18
import org.gvsig.busquedacatastral.lib.api.QueryCatastral;
19
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
20
import org.gvsig.busquedacatastral.lib.impl.ws.classes.CallejeroWSResponse;
21
import org.gvsig.busquedacatastral.lib.impl.ws.classes.MunicipiosWSResponse;
22
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Callejero;
23
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaCallejero;
24
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaMunicipieror;
25
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaNumereror;
26
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Df;
27
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Muni;
28
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Municipiero;
29
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Numereror;
30
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Nump;
31
import org.gvsig.fmap.dal.DataTypes;
32
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.fmap.dal.feature.EditableFeature;
34
import org.gvsig.fmap.dal.feature.EditableFeatureType;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.dynobject.DynObject;
38
import org.gvsig.tools.exception.BaseException;
39
import org.gvsig.tools.i18n.I18nManager;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

  
43
public class NumerosFactory extends WSObjectsFactory{
44

  
45
    private static final Logger logger = LoggerFactory
46
        .getLogger(NumerosFactory.class);
47

  
48

  
49
    public NumerosFactory(BusquedaCatastralManager manager){
50
        super(manager);
51
    }
52

  
53
    private QueryCatastral query;
54
    private String ini;
55
    private String fin;
56

  
57
    public List<String> getNumeros(QueryCatastral query, String ini, String fin) throws BusquedaCatastralGettingParamsException{
58
        if (query==null||query.getProvincia()==null){
59
            logger.error("Provincia no informada");
60
            I18nManager i18nManager = ToolsLocator.getI18nManager();
61
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_provincia_not_informed"), null);
62
        }
63
        if (query.getMunicipio()==null){
64
            logger.error("Municipio no informado");
65
            I18nManager i18nManager = ToolsLocator.getI18nManager();
66
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_municipio_not_informed"), null);
67
        }
68
        if (query.getTipoVia()==null){
69
            logger.error("Tipo Via no informado");
70
            I18nManager i18nManager = ToolsLocator.getI18nManager();
71
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_tipo_via_not_informed"), null);
72
        }
73
        if (query.getVia()==null){
74
            logger.error("Via no informado");
75
            I18nManager i18nManager = ToolsLocator.getI18nManager();
76
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_via_not_informed"), null);
77
        }
78
        if (StringUtils.isEmpty(ini) && StringUtils.isEmpty(fin)){
79
            logger.error("Numeros no informado");
80
            I18nManager i18nManager = ToolsLocator.getI18nManager();
81
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_numero_not_informed"), null);
82
        }
83
        this.query=query;
84
        this.ini=ini;
85
        this.fin=fin;
86
        Set<String> numeros=getNumeros(ini,fin);
87
        Set<String> results = new HashSet<>();
88
        for (String numero:numeros){
89

  
90
            Set<String> consulta=null;
91
            try {
92
                consulta = consultaNumerero(numero);
93
            } catch (Exception e) {
94
                //Do nothing; It is possible that there is not a given number in the interval
95
                //So no exception is thrown.
96
                logger.warn("No se ha podido encontar el n?mero: "+numero, e);
97
            }
98

  
99
            if (consulta!=null){
100
                results.addAll(consulta);
101
            }
102
        }
103
        if (results==null || results.isEmpty()){
104
            logger.error("No se ha encontrado ningun numero");
105
            I18nManager i18nManager = ToolsLocator.getI18nManager();
106
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_numero_not_found_for_parameters"), null);
107
        }
108
        return new ArrayList<String>(results);
109
    }
110

  
111
    private Set<String> getNumeros(String ini,String fin){
112
        Set<String> numeros = new HashSet<>();
113
        if (StringUtils.isNotEmpty(ini) && StringUtils.isNotEmpty(fin)){
114
            numeros.add(ini);
115
            numeros.add(fin);
116
            try {
117
                int numIni=Integer.valueOf(ini);
118
                int numFin=Integer.valueOf(fin);
119
                if (numIni<numFin){
120
                    for (int i=numIni+1;i<numFin;i++){
121
                        numeros.add(String.valueOf(i));
122
                    }
123
                }
124
            } catch (NumberFormatException e) {
125
                // Do nothing
126
            }
127
        }else{
128
            if (StringUtils.isNotEmpty(ini)){
129
                numeros.add(ini);
130
            }else if (StringUtils.isNotEmpty(fin)){
131
                numeros.add(fin);
132
            }
133
        }
134
        return numeros;
135
    }
136

  
137
    private Set<String> consultaNumerero(String numero) throws BusquedaCatastralGettingParamsException{
138
        try {
139
            DynObject provincia=query.getProvincia();
140
            DynObject municipio=query.getMunicipio();
141
            DynObject via=query.getVia();
142
            String nombreProvincia=(String) provincia.getDynValue(BusquedaCatastralManager.CAMPO_PROVINCIA_NOMBRE);
143
            String nombreMunicipio=(String) municipio.getDynValue(BusquedaCatastralManager.CAMPO_MUNICIPIO_NOMBRE);
144
            String tipoViaAbrev=query.getTipoVia().getAbrev();
145
            String nombreVia=(String)via.getDynValue(BusquedaCatastralManager.CAMPO_VIA_NOMBRE);
146

  
147
            CallejeroWSResponse callejeroResponse = getCatastroWS().
148
                 obtenerNumerero(nombreProvincia, nombreMunicipio, tipoViaAbrev, nombreVia, numero);
149
            if (callejeroResponse!=null){
150
                MessageElement[] any = callejeroResponse.get_any();
151
                MessageElement me=any[0];
152
                JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaNumereror.class);
153

  
154
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
155
                InputStream input = new ByteArrayInputStream(me.getAsString().getBytes());
156
                ConsultaNumereror cn = (ConsultaNumereror) jaxbUnmarshaller.unmarshal(input);
157

  
158
                if (cn!=null && cn.getLerr()!=null){
159
                    webserviceErrors(cn.getLerr().getErr());
160
                }
161

  
162
                Numereror numerero = cn.getNumerero();
163
                return numereroToListString(numerero);
164
            }else{
165
                logger.error("Webservice response is empty");
166
                I18nManager i18nManager = ToolsLocator.getI18nManager();
167
                throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"),null);
168
            }
169

  
170
        } catch (RemoteException e) {
171
            logger.error("Error accesing webservice",e);
172
            I18nManager i18nManager = ToolsLocator.getI18nManager();
173
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e);
174
        } catch (Exception e) {
175
            logger.error("Error marshalling response from webservice",e);
176
            I18nManager i18nManager = ToolsLocator.getI18nManager();
177
            throw new BusquedaCatastralGettingParamsException(i18nManager.getTranslation("_error_reading_response_from_ws"), e);
178
        }
179

  
180
    }
181

  
182
    private Set<String> numereroToListString(Numereror numerero){
183
        if (numerero==null){
184
            return null;
185
        }
186
        Set<String> numeros=new HashSet<>();
187
        for (Nump nump:numerero.getNump()){
188
            String num = nump.getNum().getPnp();
189
            numeros.add(num);
190
        }
191
        return numeros;
192
    }
193

  
194
    @Override
195
    protected void defineType(EditableFeatureType type)
196
        throws BusquedaCatastralGettingParamsException {
197
        // Do Nothing
198

  
199
    }
200

  
201
    @Override
202
    protected void writeFileData(FeatureStore featureStore)
203
        throws BusquedaCatastralGettingParamsException, DataException {
204
      // Do Nothing
205

  
206
    }
207

  
208
    @Override
209
    protected String getExpressionQuery() {
210
     // Do Nothing
211
        return null;
212
    }
213

  
214

  
215
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/PointFactory.java
1
package org.gvsig.busquedacatastral.lib.impl;
2

  
3
import java.io.ByteArrayInputStream;
4
import java.io.InputStream;
5
import java.rmi.RemoteException;
6
import java.util.List;
7

  
8
import javax.xml.bind.JAXBContext;
9
import javax.xml.bind.Unmarshaller;
10
import javax.xml.rpc.ServiceException;
11

  
12
import org.apache.axis.message.MessageElement;
13
import org.apache.commons.lang3.StringUtils;
14
import org.gvsig.busquedacatastral.lib.api.ReferenciaCatastral;
15
import org.gvsig.busquedacatastral.lib.api.SRSCatastro;
16
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingDataException;
17
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
18
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidSRSException;
19
import org.gvsig.busquedacatastral.lib.impl.ws.OVCCoordenadasLocator;
20
import org.gvsig.busquedacatastral.lib.impl.ws.OVCCoordenadasSoap;
21
import org.gvsig.busquedacatastral.lib.impl.ws.classes.Consulta_Coordenadas;
22
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaCoord;
23
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Coord;
24
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Coords;
25
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Err;
26
import org.gvsig.fmap.geom.Geometry;
27
import org.gvsig.fmap.geom.GeometryLocator;
28
import org.gvsig.fmap.geom.exception.CreateGeometryException;
29
import org.gvsig.fmap.geom.primitive.Point;
30
import org.gvsig.tools.ToolsLocator;
31
import org.gvsig.tools.i18n.I18nManager;
32
import org.gvsig.tools.locator.LocatorException;
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

  
36
public class PointFactory {
37

  
38
    private static final Logger logger = LoggerFactory
39
        .getLogger(PointFactory.class);
40

  
41
    public Point getPoint(String referenciacatastral, SRSCatastro srs)
42
        throws BusquedaCatastralGettingDataException, BusquedaCatastralInvalidSRSException {
43

  
44
        if (StringUtils.isEmpty(referenciacatastral)){
45
            logger.error("Referencia Catastral no valida");
46
            I18nManager i18nManager = ToolsLocator.getI18nManager();
47
            throw new BusquedaCatastralGettingDataException(i18nManager.getTranslation("_error_refCatastral_not_informed"), null);
48
        }else if (srs==null){
49
            logger.error("SRS de catastro no valido");
50
            I18nManager i18nManager = ToolsLocator.getI18nManager();
51
            throw new BusquedaCatastralInvalidSRSException(i18nManager.getTranslation("_error_SRS"), null);
52
        }else{
53
            Coords coords=getCoords(referenciacatastral,srs);
54
            if (coords!=null){
55
                return getPointFromCoords(coords);
56
            }else{
57
                logger.error("No se pudieron encontrar las coordenadas para la RC: "+referenciacatastral);
58
                I18nManager i18nManager = ToolsLocator.getI18nManager();
59
                throw new BusquedaCatastralGettingDataException(i18nManager.getTranslation("_error_couldnt_get_coords"), null);
60
            }
61

  
62
        }
63
    }
64

  
65

  
66
    public Point getPoint(ReferenciaCatastral referenciacatastral, SRSCatastro srs)
67
        throws BusquedaCatastralGettingDataException, BusquedaCatastralInvalidSRSException {
68
        if (referenciacatastral==null){
69
            logger.error("Referencia Catastral no valida");
70
            I18nManager i18nManager = ToolsLocator.getI18nManager();
71
            throw new BusquedaCatastralGettingDataException(i18nManager.getTranslation("_error_refCatastral_not_informed"), null);
72
        }else{
73
            return getPoint(referenciacatastral.getRCParcial(),srs);
74
        }
75
    }
76

  
77
    private Point getPointFromCoords(Coords coords){
78
        double x;
79
        double y;
80
        for (Coord coord:coords.getCoord()){
81
            x=Double.valueOf(coord.getGeo().getXcen());
82
            y=Double.valueOf(coord.getGeo().getYcen());
83
            Point point=null;
84
            try {
85
                point= GeometryLocator.getGeometryManager().createPoint(x, y, Geometry.SUBTYPES.GEOM2D);
86
            } catch (CreateGeometryException | LocatorException e) {
87
                logger.error("Error getting center point "+e.getMessage());
88
            }
89
            return point;
90
        }
91
        return null;
92
    }
93

  
94
    private OVCCoordenadasSoap getCoordenadasWS() throws BusquedaCatastralGettingDataException{
95
        try {
96
            OVCCoordenadasLocator locator=
97
                new OVCCoordenadasLocator();
98
            OVCCoordenadasSoap coordenadasWS =
99
                locator.getOVCCoordenadasSoap();
100
            return coordenadasWS;
101
        } catch (ServiceException e) {
102
            logger.error("Error obtaining webservice",e);
103
            I18nManager i18nManager = ToolsLocator.getI18nManager();
104
            throw new BusquedaCatastralGettingDataException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e);
105
        }
106

  
107
    }
108

  
109

  
110

  
111
    private Coords getCoords(String rc,SRSCatastro srs) throws BusquedaCatastralGettingDataException{
112
        try {
113
              Consulta_Coordenadas consultaCoord = getCoordenadasWS().consulta_CPMRC("", "", srs.getCod(), rc);
114

  
115
            if (consultaCoord!=null){
116
                MessageElement[] any = consultaCoord.get_any();
117
                MessageElement me=any[0];
118
                JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaCoord.class);
119

  
120
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
121
                InputStream input = new ByteArrayInputStream(me.getAsString().getBytes());
122
                ConsultaCoord ccord = (ConsultaCoord) jaxbUnmarshaller.unmarshal(input);
123

  
124
                if (ccord!=null && ccord.getLerr()!=null){
125
                    webserviceErrors(ccord.getLerr().getErr());
126
                }
127

  
128
                return ccord.getCoordenadas();
129
            }else{
130
                logger.error("Webservice response is empty");
131
                I18nManager i18nManager = ToolsLocator.getI18nManager();
132
                throw new BusquedaCatastralGettingDataException(i18nManager.getTranslation("_error_reading_response_from_ws"),null);
133
            }
134

  
135
        } catch (RemoteException e) {
136
            logger.error("Error accesing webservice",e);
137
            I18nManager i18nManager = ToolsLocator.getI18nManager();
138
            throw new BusquedaCatastralGettingDataException(i18nManager.getTranslation("_error_obtaining_catastro_webservice"), e);
139
        } catch (Exception e) {
140
            logger.error("Error marshalling response from webservice",e);
141
            I18nManager i18nManager = ToolsLocator.getI18nManager();
142
            throw new BusquedaCatastralGettingDataException(i18nManager.getTranslation("_error_reading_response_from_ws"), e);
143
        }
144

  
145
    }
146

  
147
    private void webserviceErrors(List<Err>errores) throws BusquedaCatastralGettingParamsException{
148
        if (errores!=null && !errores.isEmpty()){
149
            StringBuilder descErrores=new StringBuilder();
150
            I18nManager i18nManager = ToolsLocator.getI18nManager();
151
            descErrores.append(i18nManager.getTranslation("_errors_found_by_ws")+":");
152
            for (Err error:errores){
153
                descErrores.append("\n"+error.getDes());
154
                logger.error(descErrores.toString());
155
                throw new BusquedaCatastralGettingParamsException(descErrores.toString(), null);
156
            }
157
        }
158
    }
159

  
160

  
161
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.3/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.impl/src/main/java/org/gvsig/busquedacatastral/lib/impl/DefaultBusquedaCatastralLibrary.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.busquedacatastral.lib.impl;
24

  
25
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralLibrary;
26
import org.gvsig.busquedacatastral.lib.api.BusquedaCatastralLocator;
27
import org.gvsig.tools.library.AbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29

  
30

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff