Revision 476

View differences:

org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.10/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.10/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.10/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.10/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.10/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.10/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.10/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.10/org.gvsig.busquedacatastral.lib/org.gvsig.busquedacatastral.lib.api/src/main/java/org/gvsig/busquedacatastral/lib/api/exceptions/BusquedaCatastralRemoteServiceException.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 BusquedaCatastralRemoteServiceException extends BusquedaCatastralException {
26

  
27
    /**
28
     *
29
     */
30
    private static final long serialVersionUID = 4675161371620871100L;
31

  
32
    private static final String MESSAGE =
33
        "An error has been produced accessing catastral server.";
34

  
35
    private static final String KEY = "BusquedaCatastralRemoteServiceException";
36

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

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

  
45
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.10/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.10/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.10/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.10/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.BusquedaCatastralException;
30
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingDataException;
31
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
32
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidSRSException;
33
import org.gvsig.fmap.geom.primitive.Point;
34
import org.gvsig.tools.dynobject.DynObject;
35

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

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

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

  
67

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

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

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

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

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

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

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

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

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

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

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

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

  
153
       /**
154
        * Devuelve los datos catastrales de la parcela en el punto indicado
155
        * @param p
156
     * @param srs
157
        * @return DynObject
158
     * @throws BusquedaCatastralException
159
        */
160
       public DynObject getDatosCatastrales(Point p, SRSCatastro srs)throws BusquedaCatastralException;
161

  
162
       /**
163
        * Devuelve los datos catastrales del codigo de la referencia catastral
164
        * @param rc
165
        * @return DynObject
166
     * @throws BusquedaCatastralException
167
        */
168
       public DynObject getDatosCatastrales(String rc)throws BusquedaCatastralException;
169

  
170
       /**
171
     * @return
172
     */
173
    public File getCacheFolder();
174

  
175
       /**
176
     * @param cacheFolder
177
     */
178
    public void setCacheFolder(File cacheFolder);
179
}
180

  
181

  
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.10/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.10/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.10/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.10</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.10/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.10</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.10/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.10/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

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

  
44
import org.slf4j.Logger;
45
import org.slf4j.LoggerFactory;
46

  
47
public class NumerosFactory extends WSObjectsFactory{
48

  
49
    private static final Logger logger = LoggerFactory
50
        .getLogger(NumerosFactory.class);
51

  
52

  
53
    public NumerosFactory(BusquedaCatastralManager manager){
54
        super(manager);
55
    }
56

  
57
    private QueryCatastral query;
58
    private String ini;
59
    private String fin;
60

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

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

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

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

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

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

  
158
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
159
                InputStream input = new ByteArrayInputStream(me.getAsString().getBytes());
160
                ConsultaNumereror cn = (ConsultaNumereror) jaxbUnmarshaller.unmarshal(input);
161

  
162
                if (cn!=null && cn.getLerr()!=null){
163
                    webserviceErrors(cn.getLerr().getErr());
164
                }
165

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

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

  
184
    }
185

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

  
198
    @Override
199
    protected void defineType(EditableFeatureType type)
200
        throws BusquedaCatastralException {
201
        // Do Nothing
202

  
203
    }
204

  
205
    @Override
206
    protected void writeFileData(FeatureStore featureStore)
207
        throws BusquedaCatastralException, DataException {
208
      // Do Nothing
209

  
210
    }
211

  
212
    @Override
213
    protected String getExpressionQuery() {
214
     // Do Nothing
215
        return null;
216
    }
217

  
218

  
219
}
org.gvsig.busquedacatastral/tags/org.gvsig.busquedacatastral-1.0.10/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

  
15
import org.gvsig.busquedacatastral.lib.api.ReferenciaCatastral;
16
import org.gvsig.busquedacatastral.lib.api.SRSCatastro;
17
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralException;
18
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingDataException;
19
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralGettingParamsException;
20
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralInvalidSRSException;
21
import org.gvsig.busquedacatastral.lib.api.exceptions.BusquedaCatastralRemoteServiceException;
22
import org.gvsig.busquedacatastral.lib.impl.ws.OVCCoordenadasLocator;
23
import org.gvsig.busquedacatastral.lib.impl.ws.OVCCoordenadasSoap;
24
import org.gvsig.busquedacatastral.lib.impl.ws.classes.Consulta_Coordenadas;
25
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.ConsultaCoord;
26
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Coord;
27
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Coords;
28
import org.gvsig.busquedacatastral.lib.impl.ws.classes.cxf.Err;
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.GeometryLocator;
31
import org.gvsig.fmap.geom.exception.CreateGeometryException;
32
import org.gvsig.fmap.geom.primitive.Point;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.i18n.I18nManager;
35
import org.gvsig.tools.locator.LocatorException;
36

  
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39

  
40
public class PointFactory {
41

  
42
    private static final Logger logger = LoggerFactory
43
        .getLogger(PointFactory.class);
44

  
45
    public Point getPoint(String referenciacatastral, SRSCatastro srs)
46
        throws BusquedaCatastralException {
47

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

  
66
        }
67
    }
68

  
69

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

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

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

  
111
    }
112

  
113

  
114

  
115
    private Coords getCoords(String rc,SRSCatastro srs) throws BusquedaCatastralException{
116
        try {
117
              Consulta_Coordenadas consultaCoord = getCoordenadasWS().consulta_CPMRC("", "", srs.getCod(), rc);
118

  
119
            if (consultaCoord!=null){
120
                MessageElement[] any = consultaCoord.get_any();
121
                MessageElement me=any[0];
122
                JAXBContext jaxbContext = JAXBContext.newInstance(ConsultaCoord.class);
123

  
124
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
125
                InputStream input = new ByteArrayInputStream(me.getAsString().getBytes());
126
                ConsultaCoord ccord = (ConsultaCoord) jaxbUnmarshaller.unmarshal(input);
127

  
128
                if (ccord!=null && ccord.getLerr()!=null){
129
                    webserviceErrors(ccord.getLerr().getErr());
130
                }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff