Changeset 19880 in osm for applications
- Timestamp:
- 2010-02-05T14:31:42+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/haiti_earthquake/hospitals/HospitalChunkCheck.groovy
r19879 r19880 40 40 } 41 41 42 def exprHospitalsInProximity = xpath.compile("count(//tag[@k = 'amenity'][@v = 'hospital']/..)") 42 43 def int countHospitalsInProximity(node) { 43 44 def bbox = buildQueryBbox(node) 44 45 def queryUrl = "http://xapi.openstreetmap.org/api/0.6/*[amenity=hospital][${bbox}]" 45 46 def xapiResponse = DOMBuilder.parse(new InputStreamReader(new URL(queryUrl).openStream(), "UTF-8")) 46 def int count = xpath.evaluate("count(//tag[@k = 'amenity'][@v = 'hospital']/..)",xapiResponse, XPathConstants.NUMBER)47 def int count = exprHospitalsInProximity.evaluate(xapiResponse, XPathConstants.NUMBER) 47 48 return count 48 49 } 49 50 51 def exprHealthFacilitiesInProximity = xpath.compile("count(//tag[@k = 'health_facility:paho_id']/..)") 50 52 def int countHealthFacilitiesInProximity(node) { 51 53 def bbox = buildQueryBbox(node) 52 54 def queryUrl = "http://xapi.openstreetmap.org/api/0.6/*[health_facility:paho_id=*][${bbox}]" 53 55 def xapiResponse = DOMBuilder.parse(new InputStreamReader(new URL(queryUrl).openStream(), "UTF-8")) 54 def int count = xpath.evaluate("count(//tag[@k = 'health_facility:paho_id']/..)",xapiResponse, XPathConstants.NUMBER)56 def int count = exprHealthFacilitiesInProximity.evaluate(xapiResponse, XPathConstants.NUMBER) 55 57 return count 56 58 } … … 59 61 def id = getHealthFacilityId(node) 60 62 def queryUrl = "http://xapi.openstreetmap.org/api/0.6/*[health_facility:paho_id=${id}]" 63 //def queryUrl = "http://osmxapi.hypercube.telascience.org/api/0.6/*[health_facility:paho_id=${id}]" 61 64 def xapiResponse = DOMBuilder.parse(new InputStreamReader(new URL(queryUrl).openStream(), "UTF-8")) 62 def int count = xpath.evaluate("count(//tag[@k = 'health_facility:paho_id'][@v = '${id}'])", xapiResponse, XPathConstants.NUMBER)65 def int count = xpath.evaluate("count(//tag[@k = 'health_facility:paho_id'][@v =${id}])", xapiResponse, XPathConstants.NUMBER) 63 66 return count > 0 64 67 } 65 68 69 def exprHealthFacilityId = xpath.compile("./tag[@k = 'health_facility:paho_id']/@v") 66 70 def getHealthFacilityId(node) { 67 return xpath.evaluate("./tag[@k = 'health_facility:paho_id']/@v",node)71 return exprHealthFacilityId.evaluate(node) 68 72 } 69 73 74 def exprName = xpath.compile("./tag[@k = 'name']/@v") 70 75 def getName(node) { 71 return xpath.evaluate("./tag[@k = 'name']/@v",node)76 return exprName.evaluate(node) 72 77 } 73 78 79 def exprId = xpath.compile("./@id") 74 80 def getNodeId(node) { 75 return xpath.evaluate("./@id",node)81 return exprId.evaluate(node) 76 82 } 77 83
Note:
See TracChangeset
for help on using the changeset viewer.