Ignore:
Timestamp:
2010-02-05T13:10:14+01:00 (14 years ago)
Author:
guggis
Message:

updated XPath expressions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/haiti_earthquake/hospitals/HospitalChunkCheck.groovy

    r19878 r19879  
    3939                return "bbox=${minLon},${minLat},${maxLon},${maxLat}"           
    4040        }
    41                
     41       
    4242        def int countHospitalsInProximity(node) {
    4343                def bbox = buildQueryBbox(node)
    4444                def queryUrl = "http://xapi.openstreetmap.org/api/0.6/*[amenity=hospital][${bbox}]"
    4545                def xapiResponse = DOMBuilder.parse(new InputStreamReader(new URL(queryUrl).openStream(), "UTF-8"))
    46                 def int  count = xpath.evaluate("count(//node/tag[@k = 'amenity'][@v = 'hospital'])", xapiResponse, XPathConstants.NUMBER)
     46                def int  count = xpath.evaluate("count(//tag[@k = 'amenity'][@v = 'hospital']/..)", xapiResponse, XPathConstants.NUMBER)
    4747                return count
    4848        }
     
    5252                def queryUrl = "http://xapi.openstreetmap.org/api/0.6/*[health_facility:paho_id=*][${bbox}]"
    5353                def xapiResponse = DOMBuilder.parse(new InputStreamReader(new URL(queryUrl).openStream(), "UTF-8"))
    54                 def int count = xpath.evaluate("count(//node/tag[@k = 'health_facility:paho_id'])", xapiResponse, XPathConstants.NUMBER)
     54                def int count = xpath.evaluate("count(//tag[@k = 'health_facility:paho_id']/..)", xapiResponse, XPathConstants.NUMBER)
    5555                return count
    5656        }
     
    6060                def queryUrl = "http://xapi.openstreetmap.org/api/0.6/*[health_facility:paho_id=${id}]"
    6161                def xapiResponse = DOMBuilder.parse(new InputStreamReader(new URL(queryUrl).openStream(), "UTF-8"))
    62                 def int count = xpath.evaluate("count(//node/tag[@k = 'health_facility:paho_id'])", xapiResponse, XPathConstants.NUMBER)
     62                def int count = xpath.evaluate("count(//tag[@k = 'health_facility:paho_id'][@v ='${id}'])", xapiResponse, XPathConstants.NUMBER)
    6363                return count > 0
    6464        }
Note: See TracChangeset for help on using the changeset viewer.