Esempio n. 1
0
    def handle_entity(self, entity):
        if "{{dupe}}" in entity.description:
            entity.tags.append("dupe")
        if "{{delete}}" in entity.description:
            entity.tags.append("delete")
        if "{{badloc}}" in entity.description:
            entity.tags.append("badlocation")
        if "{{todo}}" in entity.description:
            entity.tags.append("todo")
        if "{{trap}}" in entity.description:
            entity.tags.append("trap")
        if "{{translated}}" in entity.description:
            entity.tags.append("translated")
        entity.description = re.sub("\{\{[^}]+\}\}", "", entity.description).strip()

        entity.root = entity.id

        latLon = self.calcGeoBoxId(entity.location.lat, entity.location.lon)

        geobox = GeoBox.all()
        geobox.filter("lat =", latLon[0])
        geobox.filter("lon =", latLon[1])
        theGeoBox = geobox.get()

        if theGeoBox == None:
            theGeoBox = GeoBox(lat=latLon[0], lon=latLon[1])

        theGeoBox.attractions.append({"id": entity.id, "name": entity.name})
        theGeoBox.put()

        return entity
Esempio n. 2
0
 def handle_entity(self, entity):
     if '{{dupe}}' in entity.description: entity.tags.append('dupe')
     if '{{delete}}' in entity.description: entity.tags.append('delete')
     if '{{badloc}}' in entity.description: entity.tags.append('badlocation')
     if '{{todo}}' in entity.description: entity.tags.append('todo')
     if '{{trap}}' in entity.description: entity.tags.append('trap')
     if '{{translated}}' in entity.description: entity.tags.append('translated')
     entity.description = re.sub("\{\{[^}]+\}\}", "", entity.description).strip()
     
     entity.root = entity.id
     
     latLon = self.calcGeoBoxId(entity.location.lat, entity.location.lon)
     
     geobox = GeoBox.all()
     geobox.filter("lat =", latLon[0])
     geobox.filter("lon =", latLon[1])
     theGeoBox = geobox.get()
     
     if theGeoBox == None:
         theGeoBox = GeoBox(
             lat = latLon[0],
             lon = latLon[1]
         )
     
     theGeoBox.attractions.append({
         'id': entity.id,
         'name': entity.name
     })
     theGeoBox.put()
     
     return entity
Esempio n. 3
0
 def post(self):
     n = int(self.request.get('n'))
     l = 50
     f = self.request.get('f')
     
     import csv
     
     csvReader = csv.reader(open('attractions' + f + '.csv'))
     
     count = 1
     for row in csvReader:
         
         if count >= n and count < n + l:
             
             parts = row[1].split(',')
             lat = round(float(parts[0]), 1)
             lon = round(float(parts[1]), 1)
             
             query = GeoBox.all()
             query.filter("lat =", lat)
             query.filter("lon =", lon)
             geoBox = query.get()
             
             if geoBox:
                 keys = {}
                 for e in geoBox.attractions:
                     keys[e] = 1
                 geoBox.attractions = keys.keys()
                 geoBox.put()
             
         elif count >= n:
             
             taskqueue.add(
                 url = '/dedupe',
                 params = {
                     'n': n + l,
                     'f': f
                 }
             )
             break
         
         count = count  + 1
     
     if f < 4:
         taskqueue.add(
             url = '/dedupe',
             params = {
                 'n': n + l,
                 'f': f + 1
             }
         )
Esempio n. 4
0
    def post(self):
        n = int(self.request.get('n'))
        l = 50
        f = self.request.get('f')

        import csv

        csvReader = csv.reader(open('attractions' + f + '.csv'))

        count = 1
        for row in csvReader:

            if count >= n and count < n + l:

                parts = row[1].split(',')
                lat = round(float(parts[0]), 1)
                lon = round(float(parts[1]), 1)

                query = GeoBox.all()
                query.filter("lat =", lat)
                query.filter("lon =", lon)
                geoBox = query.get()

                if geoBox:
                    keys = {}
                    for e in geoBox.attractions:
                        keys[e] = 1
                    geoBox.attractions = keys.keys()
                    geoBox.put()

            elif count >= n:

                taskqueue.add(url='/dedupe', params={'n': n + l, 'f': f})
                break

            count = count + 1

        if f < 4:
            taskqueue.add(url='/dedupe', params={'n': n + l, 'f': f + 1})