def create_geojson(file_name): fold = os.path.dirname(file_name) name, _ = os.path.basename(file_name).split('.') output_file = os.path.join(fold, '{}.geojson'.format(name)) df = pandas.read_csv(file_name).fillna('') lat = df['lat'] lng = df['lng'] df = df.drop(columns=['lat', 'lng']) feat_list = [] failed = [] for i in range(0, len(df.index)): props = remove_np_from_dict(dict(df.loc[i])) try: f = Feature(geometry=Point((float(lng[i]), float(lat[i]))), properties=props) feat_list.append(f) except ValueError: failed.append(props) collection = FeatureCollection(feat_list) with open(output_file, 'w') as f: f.write(dumps(collection)) return output_file
def csv_to_geojson(input_file, lat_colname='GPS_LAT', long_colname='GPS_LONG', output_file='output.geojson'): fold = os.path.dirname(input_file) name, _ = os.path.basename(input_file).split('.') output_extension = os.path.splitext(output_file)[1] if output_extension != ".geojson": raise TypeError(f"Output file must be a geojson file") df = pandas.read_csv(input_file).fillna('') lat = df[lat_colname] lng = df[long_colname] df = df.drop(columns=[lat_colname, long_colname]) feat_list = [] failed = [] for i in range(0, len(df.index)): props = remove_np_from_dict(dict(df.loc[i])) try: f = Feature(geometry=Point((float(lng[i]), float(lat[i]))), properties=props) feat_list.append(f) except ValueError: failed.append(props) collection = FeatureCollection(feat_list) with open(output_file, 'w') as f: f.write(dumps(collection)) return output_file
def response(context, flow): with decoded(flow.response): if flow.match("~d pgorelease.nianticlabs.com"): env = RpcResponseEnvelopeProto() env.ParseFromString(flow.response.content) key = associate[env.response_id] value = env.returns[0] if (key == GET_MAP_OBJECTS): mor = MapObjectsResponse() mor.ParseFromString(value) print("GET_MAP_OBJECTS %i tiles" % len(mor.tiles)) features = [] for tile in mor.tiles: print("S2 Cell %i" % tile.id) for fort in tile.forts: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={"id": fort.id, "tile": tile.id, "type": "fort", "marker-color": "0000FF"}) features.append(f) for fort in tile.location4: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={"tile": tile.id, "type": "location4", "marker-color": "FFFF00"}) features.append(f) for fort in tile.location9: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={"tile": tile.id, "type": "location9", "marker-color": "00FFFF"}) features.append(f) for fort in tile.close_pokemon_a: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={"id": fort.uid, "tile": tile.id, "type": "close_pokemon_a", "marker-color": "FF0000"}) features.append(f) for fort in tile.close_pokemon_b: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={"id": fort.uid, "tile": tile.id, "type": "close_pokemon_b", "marker-color": "00FF00"}) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) f = open('get_map_objects.json', 'w') f.write(dump) elif (key == FORT_DETAILS): mor = FortDetailsOutProto() mor.ParseFromString(value) print(mor) elif (key == FORT_SEARCH): mor = FortSearchOutProto() mor.ParseFromString(value) print(mor) else: print("API: %s" % key)
def get_boundaries(gvid, sl): """ Return a cached, static geojson file of boundaries for a region :param gvid: The GVID of the region :param sl: The summary level of the subdivisions of the region. :return: """ from geojson import Feature, Point, FeatureCollection, dumps from shapely.wkt import loads from geoid.civick import GVid from os.path import join, exists from flask import send_from_directory cache_dir = aac.library.filesystem.cache('ui/geo') fn = "{}-{}.geojson".format(str(gvid), sl) fn_path = join(cache_dir, fn) if not exists(fn_path): p = aac.library.partition('census.gov-tiger-2015-counties') features = [] for i, row in enumerate(p): if row.statefp == 6: # In dev, assume counties in California gvid = GVid.parse(row.gvid) f = Feature(geometry=loads(row.geometry).simplify(0.01), properties={ 'gvid': row.gvid, 'state': gvid.state, 'county': gvid.county, 'count_name': row.name }) features.append(f) fc = FeatureCollection(features) with open(fn_path, 'w') as f: f.write(dumps(fc)) return send_from_directory(cache_dir, fn, as_attachment=False, mimetype='application/vnd.geo+json')
def request(self, mor, env): features = [] props = { "id": "player", "marker-symbol": "pitch", "title": "You", "marker-size": "large", "marker-color": "663399", "type": "player" } p = Point((mor.PlayerLng, mor.PlayerLat)) f = Feature(geometry=p, id="player", properties=props) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) self._player = dump f = open('ui/player.json', 'w') f.write(dump)
def request(self, mor, env): features = [] props = { "id": "player", "marker-symbol": "pitch", "title": "You", "marker-size": "large", "marker-color": "663399", "type": "player" } p = Point((mor.PlayerLng, mor.PlayerLat)) f = Feature(geometry=p, id="player", properties=props) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) self._player = dump f = open('ui/player.json', 'w') f.write(dump)
def get_boundaries(gvid, sl): """ Return a cached, static geojson file of boundaries for a region :param gvid: The GVID of the region :param sl: The summary level of the subdivisions of the region. :return: """ from geojson import Feature, Point, FeatureCollection, dumps from shapely.wkt import loads from geoid.civick import GVid from os.path import join, exists from flask import send_from_directory cache_dir = aac.library.filesystem.cache("ui/geo") fn = "{}-{}.geojson".format(str(gvid), sl) fn_path = join(cache_dir, fn) if not exists(fn_path): p = aac.library.partition("census.gov-tiger-2015-counties") features = [] for i, row in enumerate(p): if row.statefp == 6: # In dev, assume counties in California gvid = GVid.parse(row.gvid) f = Feature( geometry=loads(row.geometry).simplify(0.01), properties={"gvid": row.gvid, "state": gvid.state, "county": gvid.county, "count_name": row.name}, ) features.append(f) fc = FeatureCollection(features) with open(fn_path, "w") as f: f.write(dumps(fc)) return send_from_directory(cache_dir, fn, as_attachment=False, mimetype="application/vnd.geo+json")
def request(context, flow): if flow.match("~d pgorelease.nianticlabs.com"): env = RpcRequestEnvelopeProto() env.ParseFromString(flow.request.content) if ( len(env.parameter) == 0 ): print 'Failed - empty request parameters' return key = env.parameter[0].key value = env.parameter[0].value request_api[env.request_id] = key request_location[env.request_id] = (env.lat,env.long) name = Method.Name(key) name = mismatched_apis.get(name, name) #return class name when not the same as method klass = underscore_to_camelcase(name) + "Proto" try: mor = deserialize(value, "." + klass) print("Deserialized Request %s" % name) except: print("Missing Request API: %s" % name) if (key == GET_MAP_OBJECTS): features = [] props = { "id": "player", "marker-symbol": "pitch", "title": "You", "marker-size": "large", "marker-color": "663399", "type": "player" } p = Point((mor.PlayerLng, mor.PlayerLat)) f = Feature(geometry=p, id="player", properties=props) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) f = open('ui/player.json', 'w') f.write(dump)
def response(context, flow): with decoded(flow.response): if flow.match("~d pgorelease.nianticlabs.com"): env = RpcResponseEnvelopeProto() env.ParseFromString(flow.response.content) key = request_api[env.response_id] value = env.returns[0] name = Method.Name(key) name = mismatched_apis.get(name, name) #return class name when not the same as method klass = underscore_to_camelcase(name) + "OutProto" try: mor = deserialize(value, "." + klass) print("Deserialized Response %s" % name) except: print("Missing Response API: %s" % name) if (key == GET_MAP_OBJECTS): features = [] bulk = [] for cell in mor.MapCell: for fort in cell.Fort: props = { "id": fort.FortId, "LastModifiedMs": fort.LastModifiedMs, } if fort.FortType == CHECKPOINT: props["marker-symbol"] = "circle" props["title"] = "PokéStop" props["type"] = "pokestop" props["lure"] = fort.HasField('FortLureInfo') else: props["marker-symbol"] = "town-hall" props["marker-size"] = "large" props["type"] = "gym" if fort.Team == BLUE: props["marker-color"] = "0000FF" props["title"] = "Blue Gym" elif fort.Team == RED: props["marker-color"] = "FF0000" props["title"] = "Red Gym" elif fort.Team == YELLOW: props["marker-color"] = "FF0000" props["title"] = "Yellow Gym" else: props["marker-color"] = "808080" p = Point((fort.Longitude, fort.Latitude)) f = Feature(geometry=p, id=fort.FortId, properties=props) features.append(f) bulk.append(createItem("gym", fort.FortId, p, f.properties)) for spawn in cell.SpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={ "type": "spawn", "id": len(features), "title": "spawn", "marker-color": "00FF00", "marker-symbol": "garden", "marker-size": "small", }) features.append(f) bulk.append(createItem("spawnpoint", 0, p, f.properties)) for spawn in cell.DecimatedSpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={ "id": len(features), "type": "decimatedspawn", "title": "Decimated spawn", "marker-color": "000000", "marker-symbol": "monument" }) features.append(f) for pokemon in cell.WildPokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature(geometry=p, id="wild" + str(pokemon.EncounterId), properties={ "id": "wild" + str(pokemon.EncounterId), "type": "wild", "TimeTillHiddenMs": pokemon.TimeTillHiddenMs, "WillDisappear": pokemon.TimeTillHiddenMs + pokemon.LastModifiedMs, "title": "Wild %s" % Custom_PokemonName.Name(pokemon.Pokemon.PokemonId), "marker-color": "FF0000", "marker-symbol": "suitcase" }) features.append(f) bulk.append(createItem("pokemon", pokemon.EncounterId, p, f.properties)) for pokemon in cell.CatchablePokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature(geometry=p, id="catchable" + str(pokemon.EncounterId), properties={ "id": "catchable" + str(pokemon.EncounterId), "type": "catchable", "ExpirationTimeMs": pokemon.ExpirationTimeMs, "title": "Catchable %s" % Custom_PokemonName.Name(pokemon.PokedexTypeId), "marker-color": "000000", "marker-symbol": "circle" }) features.append(f) for poke in cell.NearbyPokemon: gps = request_location[env.response_id] if poke.EncounterId in pokeLocation: add = True for loc in pokeLocation[poke.EncounterId]: if gps[0] == loc[0] and gps[1] == loc[1]: add = False if add: pokeLocation[poke.EncounterId].append((gps[0], gps[1], poke.DistanceMeters/1000)) else: pokeLocation[poke.EncounterId] = [(gps[0], gps[1], poke.DistanceMeters/1000)] if len(pokeLocation[poke.EncounterId]) >= 3: lat, lon = triangulate(pokeLocation[poke.EncounterId][0],pokeLocation[poke.EncounterId][1],pokeLocation[poke.EncounterId][2]) if not math.isnan(lat) and not math.isnan(lon) : p = Point((lon, lat)) f = Feature(geometry=p, id="nearby" + str(poke.EncounterId), properties={ "id": "nearby" + str(poke.EncounterId), "type": "nearby", "title": "Nearby %s" % Custom_PokemonName.Name(poke.PokedexNumber), "marker-color": "FFFFFF", "marker-symbol": "dog-park" }) bulk.append(createItem("pokemon", poke.EncounterId, p, f.properties)) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) dumpToMap(bulk) f = open('ui/get_map_objects.json', 'w') f.write(dump)
def response(context, flow): with decoded(flow.response): if flow.match("~d pgorelease.nianticlabs.com"): env = RpcResponseEnvelopeProto() env.ParseFromString(flow.response.content) key = request_api[env.response_id] value = env.returns[0] name = Holoholo.Rpc.Method.Name(key) name = mismatched_apis.get(name, name) #return class name when not the same as method klass = underscore_to_camelcase(name) + "OutProto" try: mor = deserialize(value, "." + klass) print("Deserialized Response %s" % name) except: print("Missing Response API: %s" % name) if (key == Holoholo.Rpc.GET_MAP_OBJECTS): features = [] for cell in mor.MapCell: for fort in cell.Fort: p = Point((fort.Longitude, fort.Latitude)) if fort.FortType == Holoholo.Rpc.CHECKPOINT: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Pokestop", "marker-color": "00007F", "marker-symbol": "town-hall"}) features.append(f) else: f = None if fort.Team == BLUE: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Blue Gym", "marker-color": "0000FF", "marker-symbol": "town-hall", "marker-size": "large"}) elif fort.Team == RED: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Red Gym", "marker-color": "FF0000", "marker-symbol": "town-hall", "marker-size": "large"}) elif fort.Team == YELLOW: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Yellow Gym", "marker-color": "FFFF00", "marker-symbol": "town-hall", "marker-size": "large"}) else: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Neutral Gym", "marker-color": "808080", "marker-symbol": "town-hall", "marker-size": "large"}) features.append(f) for spawn in cell.SpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={"id": len(features), "title": "spawn", "marker-color": "00FF00", "marker-symbol": "garden"}) features.append(f) for spawn in cell.DecimatedSpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={"id": len(features), "title": "decimated spawn", "marker-color": "000000", "marker-symbol": "monument"}) features.append(f) for pokemon in cell.WildPokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature(geometry=p, id=len(features), properties={"id": len(features), "TimeTillHiddenMs": pokemon.TimeTillHiddenMs, "title": "Wild %s" % Custom_PokemonName.Name(pokemon.Pokemon.PokemonId), "marker-color": "FF0000", "marker-symbol": "suitcase"}) features.append(f) for pokemon in cell.CatchablePokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature(geometry=p, id=len(features), properties={"id": len(features), "ExpirationTimeMs": pokemon.ExpirationTimeMs, "title": "Catchable %s" % Custom_PokemonName.Name(pokemon.PokedexTypeId), "marker-color": "000000", "marker-symbol": "circle"}) features.append(f) for poke in cell.NearbyPokemon: gps = request_location[env.response_id] if poke.EncounterId in pokeLocation: add=True for loc in pokeLocation[poke.EncounterId]: if gps[0] == loc[0] and gps[1] == loc[1]: add=False if add: pokeLocation[poke.EncounterId].append((gps[0], gps[1], poke.DistanceMeters/1000)) else: pokeLocation[poke.EncounterId] = [(gps[0], gps[1], poke.DistanceMeters/1000)] if len(pokeLocation[poke.EncounterId]) >= 3: lat, lon = triangulate(pokeLocation[poke.EncounterId][0],pokeLocation[poke.EncounterId][1],pokeLocation[poke.EncounterId][2]) if not math.isnan(lat) and not math.isnan(lon) : p = Point((lon, lat)) f = Feature(geometry=p, id=len(features), properties={"id": len(features), "title": "Nearby %s" % Custom_PokemonName.Name(poke.PokedexNumber), "marker-color": "FFFFFF", "marker-symbol": "dog-park"}) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) f = open('ui/get_map_objects.json', 'w') f.write(dump)
def response(self, mor, env, req_env): gps = (req_env.lat, req_env.long) features = [] for cell in mor.MapCell: for fort in cell.Fort: props = { "id": fort.FortId, "LastModifiedMs": fort.LastModifiedMs, } if fort.FortType == CHECKPOINT: props["title"] = "PokeStop" props["type"] = "pokestop" props["lure"] = fort.HasField('FortLureInfo') else: props["type"] = "gym" props["team"] = Team.Name(fort.Team) if fort.Team == BLUE: props["title"] = "Blue Gym" elif fort.Team == RED: props["title"] = "Red Gym" elif fort.Team == YELLOW: props["title"] = "Yellow Gym" p = Point((fort.Longitude, fort.Latitude)) f = Feature(geometry=p, id=fort.FortId, properties=props) features.append(f) for spawn in cell.SpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={ "type": "spawn", "id": len(features), "title": "spawn", "marker-color": "00FF00", "marker-symbol": "garden", "marker-size": "small", }) features.append(f) for spawn in cell.DecimatedSpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={ "id": len(features), "type": "decimatedspawn", "title": "Decimated spawn", "marker-color": "000000", "marker-symbol": "monument" }) features.append(f) for pokemon in cell.WildPokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature( geometry=p, id="wild%s" % pokemon.EncounterId, properties={ "id": "wild%s" % pokemon.EncounterId, "type": "pokemon", "pokemonNumber": pokemon.Pokemon.PokemonId, "TimeTillHiddenMs": pokemon.TimeTillHiddenMs, "WillDisappear": pokemon.TimeTillHiddenMs + pokemon.LastModifiedMs, "title": "Wild %s" % Custom_PokemonName.Name(pokemon.Pokemon.PokemonId), }) features.append(f) for pokemon in cell.CatchablePokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature(geometry=p, id="catchable%s" % pokemon.EncounterId, properties={ "id": "catchable%s" % pokemon.EncounterId, "type": "pokemon", "ExpirationTimeMs": pokemon.ExpirationTimeMs, "title": "Catchable %s" % Custom_PokemonName.Name(pokemon.PokedexTypeId), "marker-color": "000000", "marker-symbol": "circle" }) features.append(f) for pokemon in cell.NearbyPokemon: p = Point((req_env.long, req_env.lat)) f = Feature(geometry=p, id="nearby%s" % pokemon.EncounterId, properties={ "id": "nearby%s" % pokemon.EncounterId, "type": "nearby", "pokedex": pokemon.PokedexNumber, "title": Custom_PokemonName.Name(pokemon.PokedexNumber), "distance": pokemon.DistanceMeters }) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) f = open('ui/get_map_objects.json', 'w') f.write(dump)
def response(context, flow): with decoded(flow.response): if flow.match("~d pgorelease.nianticlabs.com"): env = RpcResponseEnvelopeProto() env.ParseFromString(flow.response.content) key = request_api[env.response_id] value = env.returns[0] if (key == GET_MAP_OBJECTS): mor = GetMapObjectsOutProto() mor.ParseFromString(value) print("GET_MAP_OBJECTS %i cells" % len(mor.cells)) features = [] for cell in mor.cells: print("S2 Cell %i" % cell.S2CellId) for fort in cell.Fort: p = Point((fort.Longitude, fort.Latitude)) if fort.FortType == 1: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Pokestop", "marker-color": "00007F", "marker-symbol": "town-hall"}) features.append(f) else: f = None if fort.Team == BLUE: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Blue Gym", "marker-color": "0000FF", "marker-symbol": "town-hall", "marker-size": "large"}) elif fort.Team == RED: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Red Gym", "marker-color": "FF0000", "marker-symbol": "town-hall", "marker-size": "large"}) elif fort.Team == YELLOW: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Yello Gym", "marker-color": "FFFF00", "marker-symbol": "town-hall", "marker-size": "large"}) else: f = Feature(geometry=p, id=len(features), properties={"id": fort.FortId, "title": "Unclaimed Gym", "marker-color": "808080", "marker-symbol": "town-hall", "marker-size": "large"}) features.append(f) for spawn in cell.SpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={"title": "spawn", "marker-color": "00FF00", "marker-symbol": "garden"}) features.append(f) for spawn in cell.DecimatedSpawnPoint: p = Point((spawn.Longitude, spawn.Latitude)) f = Feature(geometry=p, id=len(features), properties={"title": "decimated spawn", "marker-color": "000000", "marker-symbol": "monument"}) features.append(f) for pokemon in cell.WildPokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature(geometry=p, id=len(features), properties={"title": "Wild pokemon: %i" % pokemon.Pokemon, "type": "wild pokemon", "marker-color": "FF0000", "marker-symbol": "suitcase"}) features.append(f) for pokemon in cell.CatchablePokemon: p = Point((pokemon.Longitude, pokemon.Latitude)) f = Feature(geometry=p, id=len(features), properties={"title": "Catchable pokemon: %i" % pokemon.PokedexTypeId, "type": "catchable pokemon", "marker-color": "000000", "marker-symbol": "circle"}) features.append(f) for poke in cell.NearbyPokemon: gps = request_location[env.response_id] if poke.EncounterId in pokeLocation: add=True for loc in pokeLocation[poke.EncounterId]: if gps[0] == loc[0] and gps[1] == loc[1]: add=False if add: pokeLocation[poke.EncounterId].append((gps[0], gps[1], poke.DistanceMeters/1000)) else: pokeLocation[poke.EncounterId] = [(gps[0], gps[1], poke.DistanceMeters/1000)] if len(pokeLocation[poke.EncounterId]) >= 3: lat, lon = triangulate(pokeLocation[poke.EncounterId][0],pokeLocation[poke.EncounterId][1],pokeLocation[poke.EncounterId][2]) if not math.isnan(lat) and not math.isnan(lon) : p = Point((lon, lat)) f = Feature(geometry=p, id=len(features), properties={"title": "nearby pokemon", "marker-color": "FFFFFF", "marker-symbol": "dog-park"}) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) f = open('ui/get_map_objects.json', 'w') f.write(dump) elif (key == FORT_DETAILS): mor = FortDetailsOutProto() mor.ParseFromString(value) print(mor) elif (key == FORT_SEARCH): mor = FortSearchOutProto() mor.ParseFromString(value) print(mor) else: print("API: %s" % key)
def response(context, flow): with decoded(flow.response): if flow.match("~d pgorelease.nianticlabs.com"): env = RpcResponseEnvelopeProto() env.ParseFromString(flow.response.content) key = associate[env.response_id] value = env.returns[0] if (key == GET_MAP_OBJECTS): mor = MapObjectsResponse() mor.ParseFromString(value) print("GET_MAP_OBJECTS %i tiles" % len(mor.tiles)) features = [] for tile in mor.tiles: print("S2 Cell %i" % tile.id) for fort in tile.forts: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={ "id": fort.id, "tile": tile.id, "type": "fort", "marker-color": "0000FF" }) features.append(f) for fort in tile.location4: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={ "tile": tile.id, "type": "location4", "marker-color": "FFFF00" }) features.append(f) for fort in tile.location9: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={ "tile": tile.id, "type": "location9", "marker-color": "00FFFF" }) features.append(f) for fort in tile.close_pokemon_a: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={ "id": fort.uid, "tile": tile.id, "type": "close_pokemon_a", "marker-color": "FF0000" }) features.append(f) for fort in tile.close_pokemon_b: p = Point((fort.longitude, fort.latitude)) f = Feature(geometry=p, id=len(features), properties={ "id": fort.uid, "tile": tile.id, "type": "close_pokemon_b", "marker-color": "00FF00" }) features.append(f) fc = FeatureCollection(features) dump = geojson.dumps(fc, sort_keys=True) f = open('get_map_objects.json', 'w') f.write(dump) elif (key == FORT_DETAILS): mor = FortDetailsOutProto() mor.ParseFromString(value) print(mor) elif (key == FORT_SEARCH): mor = FortSearchOutProto() mor.ParseFromString(value) print(mor) else: print("API: %s" % key)