Geolocalización¶
Sirve para obtener datos de geolocalización (para los centros sanitarios).
Configuración de wso2¶
Para poder acceder vía proxy es necesario añadir lo siguiente en deployment.toml
:
[transport.http]
preserve_http_user_agent = "true"
[[transport.http.secured_proxy_profile]]
target_hosts = [".*.openstreetmap.org"]
proxy_host = "proxy.jcyl.es"
proxy_port = 80
(posiblemente también sea necesario añadir proxy_username
y proxy_password
con los valores adecuados).
Aplicación WSO2¶
API¶
<?xml version="1.0" encoding="UTF-8"?>
<api context="/geo" name="geocodificacion" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" url-mapping="/search">
<inSequence>
<!-- Se recogen los datos de la consulta de geocodificacion-->
<property expression="fn:concat($ctx:query.param.numero, ' ', $ctx:query.param.calle)" name="uri.var.street" scope="default" type="STRING"/>
<property expression="$ctx:query.param.ciudad" name="uri.var.city" scope="default" type="STRING"/>
<property expression="$ctx:query.param.provincia" name="uri.var.county" scope="default" type="STRING"/>
<property expression="$ctx:query.param.cpostal" name="uri.var.postalcode" scope="default" type="STRING"/>
<property name="uri.var.state" scope="default" type="STRING" value="castilla y leon"/>
<property name="uri.var.country_code" scope="default" type="STRING" value="es"/>
<property name="uri.var.countrycodes" scope="default" type="STRING" value="es"/>
<property name="uri.var.acceptlanguage" scope="default" type="STRING" value="es-ES"/>
<property name="uri.var.format" scope="default" type="STRING" value="json"/>
<property name="uri.var.limit" scope="default" type="STRING" value="1"/>
<property name="uri.var.extratags" scope="default" type="STRING" value="1"/>
<property name="uri.var.namedetails" scope="default" type="STRING" value="1"/>
<property name="uri.var.email" scope="default" type="STRING" value="informatica.cesa@jcyl.es"/>
<header name="User-Agent" scope="transport" value="Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)"/>
<send>
<endpoint key="openstreet"/>
</send>
</inSequence>
<outSequence>
<!-- Se devuelven las coordenadas -->
<log description="------------------Respuesta del servidor----------------------" level="full" separator="
">
<property expression="json-eval($.[0].lat)" name="Latitud"/>
<property expression="json-eval($.[0].lon)" name="Longitud"/>
<property expression="json-eval($.[0].display_name)" name="Direccion"/>
</log>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<payloadFactory media-type="json">
<format>{"latitud": "$1", "longitud": "$2"}
</format>
<args>
<arg evaluator="json" expression="$.[0].lat"/>
<arg evaluator="json" expression="$.[0].lon"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<send/>
</outSequence>
<faultSequence>
<log level="full" separator="
">
<property name="Error" value="Algo esta fallando"/>
<property expression="get-property('ERROR_MESSAGE')" name="Mensaje de error"/>
</log>
</faultSequence>
</resource>
</api>
End-point¶
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="openstreet" xmlns="http://ws.apache.org/ns/synapse">
<http method="get" uri-template="https://nominatim.openstreetmap.org/search?street={uri.var.street}&city={uri.var.city}&county={uri.var.county}&postalcode={uri.var.postalcode}&state={uri.var.state}&country_code={uri.var.country_code}&countrycodes={uri.var.countrycodes}&accept-language={uri.var.acceptlanguage}&format={uri.var.format}&limit={uri.var.limit}&extratags={uri.var.extratags}&namedetails={uri.var.namedetails}&email={uri.var.email}">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
Última actualización:
April 22, 2022