Skip to content

Commit

Permalink
Slightly change behavior for user definer projection when layer is ad…
Browse files Browse the repository at this point in the history
…ded/removed + Prepare for 0.3.5
  • Loading branch information
mz committed Jun 28, 2017
1 parent 4cd8c8f commit 943b59f
Show file tree
Hide file tree
Showing 12 changed files with 965 additions and 1,033 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changes
=======

0.3.5 (2017-06-28)
------------------

- Allow to edit the location of proportionnal symbols

- Slightly change the behavior with proj4 projections when layers are added/removed


0.3.4 (2017-06-22)
------------------

Expand Down
2 changes: 1 addition & 1 deletion magrit_app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = '0.3.4'
__version__ = '0.3.5'
23 changes: 16 additions & 7 deletions magrit_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ def get_user_id(session_redis, app_users, app=None):
app_users.add(user_id)
return user_id


def read_shp_crs(path):
with open(path, 'r') as f:
proj_info_str = f.read()
return proj_info_str


def convert_error(message='Error converting input file'):
return web.Response(text='{{"Error": "{}"}}'.format(message))

Expand Down Expand Up @@ -273,9 +280,14 @@ async def convert(request):
request.app['logger'].debug(
'{} - Used result from redis'.format(user_id))
request.app['redis_conn'].pexpire(f_name, 86400000)
if "shp" in datatype:
proj_info_str = read_shp_crs('/tmp/' + name.replace('.shp', '.prj'))

return web.Response(text=''.join(
['{"key":', str(hashed_input), ',"file":', result.decode(), '}']
))
['{"key":', str(hashed_input),
',"file":', result.decode(),
',"proj":', json.dumps(get_proj4_string(proj_info_str)),
'}']))

if "shp" in datatype:
clean_files = lambda: [os.remove(_file) for _file in list_files]
Expand All @@ -292,10 +304,8 @@ async def convert(request):

asyncio.ensure_future(
request.app['redis_conn'].set(f_name, result, pexpire=86400000))
with open('/tmp/' + name.replace('.shp', '.prj'), 'r') as f:
proj_info_str = f.read()
proj_info_str = read_shp_crs('/tmp/' + name.replace('.shp', '.prj'))
clean_files()

elif datatype in ('application/x-zip-compressed', 'application/zip'):
dataZip = BytesIO(data)
dir_path = '/tmp/{}{}/'.format(user_id, hashed_input)
Expand Down Expand Up @@ -339,8 +349,7 @@ async def convert(request):
if not result:
return convert_error()

with open(slots['prj'], 'r') as f:
proj_info_str = f.read()
proj_info_str = read_shp_crs(slots['prj'])

asyncio.ensure_future(
request.app['redis_conn'].set(
Expand Down

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions magrit_app/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1757,6 +1757,13 @@ function remove_layer_cleanup(name){
document.getElementById('btn_type_fields').setAttribute('disabled', 'true');

reset_user_values();

// Reset the projection (if the projection was defined via proj4):
if (current_proj_name === 'def_proj4') {
current_proj_name = 'NaturalEarth2';
change_projection(current_proj_name);
addLastProjectionSelect(current_proj_name);
}
}

// There is probably better ways in JS to delete the object,
Expand Down
2 changes: 1 addition & 1 deletion magrit_app/static/json/list_symbols.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["city_large.png","city_small.png","parking.png","fountain.png","gas.png","tourist_view_point.png","phone.png","amenity=restaurant.png","car.png","tourist_museum.png","education_university.png","food_fastfood.png","city_building.png","landuse_coniferous.png","skull.png","landuse_grass.png","parachute.png","food_drinkingtap.png","tourist_cinema.png","boat.png","disability_accessibility.png","question.png","tourist_steam_train.png","deer.png","landuse_swamp.png","disability_lowvision.png","poi_place_city.png","poi_place_town.png","tourist_memorial.png","tourist_fountain.png","tourist_casino.png","amenity=bar.png","education_school.png","poi_tower_communications.png","house.png","tourist_ruin.png","plane.png","amenity=fire_station.png","poi_embassy2.png","golf.png","tourist_zoo.png","bank.png","amenity=hospital.png","tourist_theatre.png","tourist_castle.png","food_pub.png","cross.png","amenity=pub.png","landuse_coniferous_and_deciduous.png","couple.png","fish.png","tourisum_fountain.png","poi_embassy.png","landuse_quary.png","tourist_windmill.png","tourist_archaeological.png","poi_tower_power.png","poi_peak.png","tourist_waterwheel.png","teepee.png","food_cafe.png","tourist_monument.png","city_medium.png","poi_cave.png","shipwreck.png","poi_mine.png","amenity=fast_food.png","tourist_picnic.png","amenity=theatre.png","poi_point_of_interest.png","swimmer.png","landuse_deciduous.png","tourist_battlefield.png","education_nursery.png","tourist_wreck.png","skier.png","amenity=police.png","poi_tower_water.png","poi_military_bunker.png","camera.png","poi_boundary_administrative.png","tourist_beach.png","landuse_hills.png","poi_place_village.png","tourist_art_gallery2.png","food_bar.png","anchor.png","waypoint.png","walker.png","landuse_scrub.png","h.png","flag.png"]
["amenity=pub.png","anchor.png","phone.png","tourist_picnic.png","education_nursery.png","tourist_cinema.png","fountain.png","tourist_archaeological.png","disability_accessibility.png","golf.png","gas.png","tourisum_fountain.png","landuse_swamp.png","amenity=hospital.png","food_cafe.png","car.png","landuse_grass.png","poi_place_town.png","fish.png","tourist_memorial.png","landuse_scrub.png","tourist_art_gallery2.png","house.png","poi_military_bunker.png","amenity=police.png","amenity=restaurant.png","tourist_zoo.png","skull.png","poi_tower_water.png","poi_cave.png","amenity=fire_station.png","tourist_windmill.png","tourist_museum.png","poi_boundary_administrative.png","landuse_coniferous.png","education_university.png","tourist_wreck.png","poi_embassy.png","plane.png","food_bar.png","h.png","swimmer.png","poi_mine.png","tourist_monument.png","poi_place_city.png","tourist_view_point.png","poi_place_village.png","city_small.png","city_building.png","flag.png","tourist_casino.png","education_school.png","tourist_theatre.png","poi_embassy2.png","tourist_castle.png","skier.png","landuse_hills.png","tourist_ruin.png","city_large.png","amenity=bar.png","poi_tower_communications.png","tourist_fountain.png","teepee.png","waypoint.png","parachute.png","couple.png","poi_tower_power.png","food_drinkingtap.png","camera.png","city_medium.png","question.png","landuse_deciduous.png","tourist_beach.png","amenity=theatre.png","food_pub.png","tourist_battlefield.png","shipwreck.png","disability_lowvision.png","walker.png","boat.png","poi_point_of_interest.png","amenity=fast_food.png","poi_peak.png","cross.png","landuse_coniferous_and_deciduous.png","tourist_waterwheel.png","landuse_quary.png","parking.png","tourist_steam_train.png","bank.png","deer.png","food_fastfood.png"]
4 changes: 2 additions & 2 deletions magrit_app/templates/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title> {{ app_name }} </title>
<link rel="icon" type="image/png" href="static/img/favicon.png" />
<link href="static/css/scoped-bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="static/css/style.9342a7922585.min.css" rel="stylesheet" type="text/css">
<link href="static/css/style.454f8bbc5b05.min.css" rel="stylesheet" type="text/css">
<link href="static/css/vanilla-dataTables.min.css" rel="stylesheet" type="text/css">
<link href="static/css/alertify.min.css" rel="stylesheet" type="text/css">
<link href="static/css/semantic.min.css" rel="stylesheet" type="text/css">
Expand Down Expand Up @@ -51,6 +51,6 @@
</div>
</noscript>
<script src="static/js/lib/bootstrap-native3.mod.min.js"></script>
<script src="static/js/app.9342a7922585.js"></script>
<script src="static/js/app.454f8bbc5b05.js"></script>
</body>
</html>
13 changes: 0 additions & 13 deletions misc/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ def save_version(version):
f.write("# -*- coding: utf-8 -*-\n\n__version__ = '{}'\n".format(version))


# def replace_version_docker_file(old_version, new_version):
# with open('../misc/Docker/app/Dockerfile', 'r') as f:
# data = f.read()
# with open('../misc/Docker/app/Dockerfile', 'w') as f:
# f.write(data.replace(old_version, new_version))
#
# with open('../misc/dockerfiles/Dockerfile', 'r') as f:
# data = f.read()
# with open('../misc/dockerfiles/Dockerfile', 'w') as f:
# f.write(data.replace(old_version, new_version))


if __name__ == '__main__':
os.chdir(os.path.dirname(os.path.realpath(__file__)))
os.chdir('../magrit_app')
Expand All @@ -46,5 +34,4 @@ def save_version(version):
current_version[0] += 1
current_version_txt = '.'.join(map(str, current_version))
save_version(current_version_txt)
# replace_version_docker_file(old_version, current_version_txt)
print(old_version, ' -> ', current_version_txt)

0 comments on commit 943b59f

Please sign in to comment.