├── .gitignore ├── LICENSE ├── README.md ├── dajaxice ├── __init__.py ├── core │ ├── Dajaxice.py │ └── __init__.py ├── decorators.py ├── exceptions.py ├── finders.py ├── models.py ├── templates │ └── dajaxice │ │ ├── dajaxice.core.js │ │ ├── dajaxice_function_loop.js │ │ └── dajaxice_module_loop.js ├── templatetags │ ├── __init__.py │ └── dajaxice_templatetags.py ├── tests │ ├── __init__.py │ ├── ajax.py │ ├── requirements.txt │ └── urls.py ├── urls.py ├── utils.py └── views.py ├── example ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png └── 6.png ├── giscube ├── __init__.py ├── config.py ├── settings.py ├── urls.py └── wsgi.py ├── giscube_app ├── __init__.py ├── ajax.py ├── forms.py ├── models.py ├── scripts │ ├── __init__.py │ ├── clip_geotiff_by_shp.py │ ├── conversion.py │ ├── data_management.py │ ├── extract_shp_table.py │ ├── gtif_to_tile.py │ ├── metadata.py │ ├── open_file.py │ ├── opendap.py │ ├── spatial_analysis.py │ └── what_file.py ├── static │ ├── css │ │ ├── .DS_Store │ │ ├── OpenLayer_style.css │ │ ├── bootstrap-glyphicons.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── bootstrap_2.3.css │ │ ├── jquery.fileupload-ui.css │ │ ├── jquery.fileupload.css │ │ ├── leaflet-0.6.4_leaflet.css │ │ ├── leaflet-0.6.4_leaflet.ie.css │ │ ├── ol.css │ │ ├── side_menu.css │ │ └── style.css │ ├── db.sqlite3 │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ └── glyphicons-halflings-regular.woff │ ├── img │ │ ├── .DS_Store │ │ ├── giscube.svg │ │ ├── github.png │ │ ├── glyphicons-halflings-white.png │ │ ├── glyphicons-halflings.png │ │ ├── logo.png │ │ └── logo_beta.png │ ├── js │ │ ├── .DS_Store │ │ ├── KML.js │ │ ├── OpenLayers.js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── collapse.js │ │ ├── jquery.fileupload-process.js │ │ ├── jquery.fileupload-ui.js │ │ ├── jquery.fileupload.js │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ ├── jquery.ui.widget.js │ │ ├── jquery.xdr-transport.js │ │ ├── kml-layer.js │ │ ├── leaflet-0.6.4_leaflet.js │ │ ├── leaflet.filelayer.js │ │ ├── main.js │ │ ├── ol.js │ │ ├── togeojson.js │ │ └── transition.js │ └── uploaded_files │ │ └── .DS_Store ├── templates │ ├── data_information │ │ └── index.html │ ├── data_resource │ │ └── index.html │ ├── data_visualiser │ │ └── index.html │ ├── footer.html │ ├── header.html │ └── tools │ │ ├── buffer_shp.html │ │ ├── clip_geotiff_by_shp.html │ │ ├── color_table_geotiff.html │ │ ├── coord_to_point_shp.html │ │ ├── extract_shp_table.html │ │ ├── geotiff_resolution.html │ │ ├── geotiff_to_kml.html │ │ ├── index.html │ │ ├── ncdump_header.html │ │ ├── ncdump_whole_netcdf.html │ │ ├── netcdf_to_geojson.html │ │ ├── netcdf_to_geotiff.html │ │ ├── point_inside_shapefile.html │ │ ├── re_project_geotiff.html │ │ ├── re_project_shapefile.html │ │ ├── shp_to_json.html │ │ ├── shp_to_kml.html │ │ ├── shp_to_tif.html │ │ ├── tif_to_point_json.html │ │ └── tif_to_point_shp.html ├── templatetags │ ├── __init__.py │ ├── extract_shp_table.py │ ├── nc_dict.py │ ├── netcdf_dict.py │ ├── re-project.py │ ├── shp_dict.py │ └── tif_dict.py ├── urls.py └── views.py ├── manage.py └── vagrant.zip /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | bin/ 10 | build/ 11 | develop-eggs/ 12 | dist/ 13 | eggs/ 14 | lib/ 15 | lib64/ 16 | parts/ 17 | sdist/ 18 | var/ 19 | *.egg-info/ 20 | .installed.cfg 21 | *.egg 22 | 23 | # Installer logs 24 | pip-log.txt 25 | pip-delete-this-directory.txt 26 | 27 | # Unit test / coverage reports 28 | .tox/ 29 | .coverage 30 | .cache 31 | nosetests.xml 32 | coverage.xml 33 | 34 | # Translations 35 | *.mo 36 | 37 | *.nc 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![alt tag](https://github.com/MBoustani/GISCube/blob/master/giscube_app/static/img/logo.png) 2 | 3 | [Demo video](http://youtu.be/iV7SvP-gil4) 4 | ======= 5 | 6 | ##Web Based GIS Application 7 | 8 | 9 | Beside some open source GIS libraries and some software like ArcGIS there are comparatively few open source, web-based and easy to use application that are capable of doing GIS processing and visualization. To address this, we present GISCube, an open source web-based GIS application that can store, visualize and process GIS and GeoSpatial data. GISCube is powered by [Geothon](https://github.com/MBoustani/Geothon), an open source python GIS cookbook. Geothon has a variety of Geoprocessing tools such data conversion, processing, spatial analysis and data management tools. GISCube has the capability of supporting a variety of well known GIS data formats in both vector and raster formats, and the system is being expanded to support NASA’s and scientific data formats such as netCDF and HDF files. 10 | 11 | 12 | ##Installation (vagrant) 13 | 14 | 1- [Install Vagrant (v 1.8.1)](https://docs.vagrantup.com/v2/installation/) 15 | 16 | 2- [Install VirtualBox (v 5.0.16)](https://www.virtualbox.org/wiki/Downloads) 17 | 18 | 3- Download [vagrant.zip](https://github.com/MBoustani/GISCube/blob/master/vagrant.zip?raw=true) 19 | 20 | 4- Unzip vagrant.zip 21 | 22 | 5- `cd vagrant` 23 | 24 | 6- `vagrant up` 25 | 26 | 7-`vagrant ssh` 27 | 28 | 8- `cd GISCube` 29 | 30 | 9- `python manage.py runserver 0.0.0.0:5050` 31 | 32 | 10- open [localhost:5050](http://localhost:5050) in browser and enjoy. 33 | 34 | 11- To exit the VM (vagrant) type `exit` 35 | 36 | 12- To remove/destroy VM, exit vagarnat first then type `vagrant destroy` 37 | 38 | ##Documentation 39 | [Documentation](https://github.com/MBoustani/GISCube/wiki) 40 | 41 | ##Example 42 | In this example, we are going to use "Clip GeoTIIF" tool to clip a GeoTIFF using Shapefile. 43 | [Example](https://github.com/MBoustani/GISCube/wiki/Example) 44 | -------------------------------------------------------------------------------- /dajaxice/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = (0, 7, 'beta') 2 | -------------------------------------------------------------------------------- /dajaxice/core/Dajaxice.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from django.utils.importlib import import_module 4 | 5 | log = logging.getLogger('dajaxice') 6 | 7 | 8 | class DajaxiceFunction(object): 9 | """ Basic representation of a dajaxice ajax function.""" 10 | 11 | def __init__(self, function, name, method): 12 | self.function = function 13 | self.name = name 14 | self.method = method 15 | 16 | def call(self, *args, **kwargs): 17 | """ Call the function. """ 18 | return self.function(*args, **kwargs) 19 | 20 | 21 | class DajaxiceModule(object): 22 | """ Basic representation of a dajaxice module. """ 23 | 24 | def __init__(self, name=None): 25 | self.name = name 26 | self.functions = {} 27 | self.submodules = {} 28 | 29 | def add(self, name, function): 30 | """ Add this function at the ``name`` deep. If the submodule already 31 | exists, recusively call the add method into the submodule. If not, 32 | create the module and call the add method.""" 33 | 34 | # If this is not the final function name (there are more modules) 35 | # split the name again an register a new submodule. 36 | if '.' in name: 37 | module, extra = name.split('.', 1) 38 | if module not in self.submodules: 39 | self.submodules[module] = DajaxiceModule(module) 40 | self.submodules[module].add(extra, function) 41 | else: 42 | self.functions[name] = function 43 | 44 | 45 | class Dajaxice(object): 46 | 47 | def __init__(self): 48 | self._registry = {} 49 | self._modules = None 50 | 51 | def register(self, function, name=None, method='POST'): 52 | """ 53 | Register this function as a dajaxice function. 54 | 55 | If no name is provided, the module and the function name will be used. 56 | The final (customized or not) must be unique. """ 57 | 58 | method = self.clean_method(method) 59 | 60 | # Generate a default name 61 | if not name: 62 | module = ''.join(str(function.__module__).rsplit('.ajax', 1)) 63 | name = '.'.join((module, function.__name__)) 64 | 65 | if ':' in name: 66 | log.error('Ivalid function name %s.' % name) 67 | return 68 | 69 | # Check for already registered functions 70 | if name in self._registry: 71 | log.error('%s was already registered.' % name) 72 | return 73 | 74 | # Create the dajaxice function. 75 | function = DajaxiceFunction(function=function, 76 | name=name, 77 | method=method) 78 | 79 | # Register this new ajax function 80 | self._registry[name] = function 81 | 82 | def is_callable(self, name, method): 83 | """ Return if the function callable or not. """ 84 | return name in self._registry and self._registry[name].method == method 85 | 86 | def clean_method(self, method): 87 | """ Clean the http method. """ 88 | method = method.upper() 89 | if method not in ['GET', 'POST']: 90 | method = 'POST' 91 | return method 92 | 93 | def get(self, name): 94 | """ Return the dajaxice function.""" 95 | return self._registry[name] 96 | 97 | @property 98 | def modules(self): 99 | """ Return an easy to loop module hierarchy with all the functions.""" 100 | if not self._modules: 101 | self._modules = DajaxiceModule() 102 | for name, function in self._registry.items(): 103 | self._modules.add(name, function) 104 | return self._modules 105 | 106 | LOADING_DAJAXICE = False 107 | 108 | 109 | def dajaxice_autodiscover(): 110 | """ 111 | Auto-discover INSTALLED_APPS ajax.py modules and fail silently when 112 | not present. NOTE: dajaxice_autodiscover was inspired/copied from 113 | django.contrib.admin autodiscover 114 | """ 115 | global LOADING_DAJAXICE 116 | if LOADING_DAJAXICE: 117 | return 118 | LOADING_DAJAXICE = True 119 | 120 | import imp 121 | from django.conf import settings 122 | 123 | for app in settings.INSTALLED_APPS: 124 | 125 | try: 126 | app_path = import_module(app).__path__ 127 | except AttributeError: 128 | continue 129 | 130 | try: 131 | imp.find_module('ajax', app_path) 132 | except ImportError: 133 | continue 134 | 135 | import_module("%s.ajax" % app) 136 | 137 | LOADING_DAJAXICE = False 138 | -------------------------------------------------------------------------------- /dajaxice/core/__init__.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | 3 | from Dajaxice import Dajaxice, dajaxice_autodiscover 4 | 5 | 6 | class DajaxiceConfig(object): 7 | """ Provide an easy to use way to read the dajaxice configuration and 8 | return the default values if no configuration is present.""" 9 | 10 | default_config = {'DAJAXICE_XMLHTTPREQUEST_JS_IMPORT': True, 11 | 'DAJAXICE_JSON2_JS_IMPORT': True, 12 | 'DAJAXICE_EXCEPTION': 'DAJAXICE_EXCEPTION', 13 | 'DAJAXICE_MEDIA_PREFIX': 'dajaxice'} 14 | 15 | def __getattr__(self, name): 16 | """ Return the customized value for a setting (if it exists) or the 17 | default value if not. """ 18 | 19 | if name in self.default_config: 20 | if hasattr(settings, name): 21 | return getattr(settings, name) 22 | return self.default_config.get(name) 23 | return None 24 | 25 | @property 26 | def dajaxice_url(self): 27 | return r'^%s/' % self.DAJAXICE_MEDIA_PREFIX 28 | 29 | @property 30 | def django_settings(self): 31 | return settings 32 | 33 | @property 34 | def modules(self): 35 | return dajaxice_functions.modules 36 | 37 | dajaxice_functions = Dajaxice() 38 | dajaxice_config = DajaxiceConfig() 39 | -------------------------------------------------------------------------------- /dajaxice/decorators.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | from dajaxice.core import dajaxice_functions 4 | 5 | 6 | def dajaxice_register(*dargs, **dkwargs): 7 | """ Register some function as a dajaxice function 8 | 9 | For legacy purposes, if only a function is passed register it a simple 10 | single ajax function using POST, i.e: 11 | 12 | @dajaxice_register 13 | def ajax_function(request): 14 | ... 15 | 16 | After 0.5, dajaxice allow to customize the http method and the final name 17 | of the registered function. This decorator covers both the legacy and 18 | the new functionality, i.e: 19 | 20 | @dajaxice_register(method='GET') 21 | def ajax_function(request): 22 | ... 23 | 24 | @dajaxice_register(method='GET', name='my.custom.name') 25 | def ajax_function(request): 26 | ... 27 | 28 | You can also register the same function to use a different http method 29 | and/or use a different name. 30 | 31 | @dajaxice_register(method='GET', name='users.get') 32 | @dajaxice_register(method='POST', name='users.update') 33 | def ajax_function(request): 34 | ... 35 | """ 36 | 37 | if len(dargs) and not dkwargs: 38 | function = dargs[0] 39 | dajaxice_functions.register(function) 40 | return function 41 | 42 | def decorator(function): 43 | @functools.wraps(function) 44 | def wrapper(request, *args, **kwargs): 45 | return function(request, *args, **kwargs) 46 | dajaxice_functions.register(function, *dargs, **dkwargs) 47 | return wrapper 48 | return decorator 49 | -------------------------------------------------------------------------------- /dajaxice/exceptions.py: -------------------------------------------------------------------------------- 1 | class DajaxiceError(Exception): 2 | pass 3 | 4 | 5 | class FunctionNotCallableError(DajaxiceError): 6 | pass 7 | 8 | 9 | class DajaxiceImportError(DajaxiceError): 10 | pass 11 | -------------------------------------------------------------------------------- /dajaxice/finders.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | 4 | from django.contrib.staticfiles import finders 5 | from django.template import Context 6 | from django.template.loader import get_template 7 | from django.core.exceptions import SuspiciousOperation 8 | 9 | 10 | class VirtualStorage(finders.FileSystemStorage): 11 | """" Mock a FileSystemStorage to build tmp files on demand.""" 12 | 13 | def __init__(self, *args, **kwargs): 14 | self._files_cache = {} 15 | super(VirtualStorage, self).__init__(*args, **kwargs) 16 | 17 | def get_or_create_file(self, path): 18 | if path not in self.files: 19 | return '' 20 | 21 | data = getattr(self, self.files[path])() 22 | 23 | try: 24 | current_file = open(self._files_cache[path]) 25 | current_data = current_file.read() 26 | current_file.close() 27 | if current_data != data: 28 | os.remove(path) 29 | raise Exception("Invalid data") 30 | except Exception: 31 | handle, tmp_path = tempfile.mkstemp() 32 | tmp_file = open(tmp_path, 'w') 33 | tmp_file.write(data) 34 | tmp_file.close() 35 | self._files_cache[path] = tmp_path 36 | 37 | return self._files_cache[path] 38 | 39 | def exists(self, name): 40 | return name in self.files 41 | 42 | def listdir(self, path): 43 | folders, files = [], [] 44 | for f in self.files: 45 | if f.startswith(path): 46 | f = f.replace(path, '', 1) 47 | if os.sep in f: 48 | folders.append(f.split(os.sep, 1)[0]) 49 | else: 50 | files.append(f) 51 | return folders, files 52 | 53 | def path(self, name): 54 | try: 55 | path = self.get_or_create_file(name) 56 | except ValueError: 57 | raise SuspiciousOperation("Attempted access to '%s' denied." % name) 58 | return os.path.normpath(path) 59 | 60 | 61 | class DajaxiceStorage(VirtualStorage): 62 | 63 | files = {os.path.join('dajaxice', 'dajaxice.core.js'): 'dajaxice_core_js'} 64 | 65 | def dajaxice_core_js(self): 66 | from dajaxice.core import dajaxice_autodiscover, dajaxice_config 67 | 68 | dajaxice_autodiscover() 69 | 70 | c = Context({'dajaxice_config': dajaxice_config}) 71 | return get_template(os.path.join('dajaxice', 'dajaxice.core.js')).render(c) 72 | 73 | 74 | class DajaxiceFinder(finders.BaseStorageFinder): 75 | storage = DajaxiceStorage() 76 | -------------------------------------------------------------------------------- /dajaxice/models.py: -------------------------------------------------------------------------------- 1 | # Don't delete me 2 | -------------------------------------------------------------------------------- /dajaxice/templates/dajaxice/dajaxice_function_loop.js: -------------------------------------------------------------------------------- 1 | {% for function_name, function in module.functions.items %} 2 | {{ function_name }}: function(callback_function, argv, custom_settings){ 3 | return Dajaxice.call('{{ function.name }}', '{{ function.method }}', callback_function, argv, custom_settings); 4 | }{% if not forloop.last or top or module.submodules %},{% endif %} 5 | {% endfor %} 6 | -------------------------------------------------------------------------------- /dajaxice/templates/dajaxice/dajaxice_module_loop.js: -------------------------------------------------------------------------------- 1 | {{ name }}: { 2 | {% include "dajaxice/dajaxice_function_loop.js" %} 3 | {% with parent_foorloop=forloop %} 4 | {% for name, sub_module in module.submodules.items %} 5 | {% with filename="dajaxice/dajaxice_module_loop.js" module=sub_module %} 6 | {% include filename %} 7 | {% endwith %} 8 | {% if not forloop.last %},{% endif %} 9 | {% endfor %} 10 | } 11 | {% endwith %} 12 | -------------------------------------------------------------------------------- /dajaxice/templatetags/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/dajaxice/templatetags/__init__.py -------------------------------------------------------------------------------- /dajaxice/templatetags/dajaxice_templatetags.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from django import template 4 | from django.middleware.csrf import get_token 5 | from django.conf import settings 6 | from django.core.files.storage import get_storage_class 7 | 8 | staticfiles_storage = get_storage_class(settings.STATICFILES_STORAGE)() 9 | 10 | register = template.Library() 11 | 12 | log = logging.getLogger('dajaxice') 13 | 14 | 15 | @register.simple_tag(takes_context=True) 16 | def dajaxice_js_import(context, csrf=True): 17 | """ Return the js script tag for the dajaxice.core.js file 18 | If the csrf argument is present and it's ``nocsrf`` dajaxice will not 19 | try to mark the request as if it need the csrf token. By default use 20 | the dajaxice_js_import template tag will make django set the csrftoken 21 | cookie on the current request.""" 22 | 23 | csrf = csrf != 'nocsrf' 24 | request = context.get('request') 25 | 26 | if request and csrf: 27 | get_token(request) 28 | elif csrf: 29 | log.warning("The 'request' object must be accesible within the " 30 | "context. You must add 'django.contrib.messages.context" 31 | "_processors.request' to your TEMPLATE_CONTEXT_PROCESSORS " 32 | "and render your views using a RequestContext.") 33 | 34 | url = staticfiles_storage.url('dajaxice/dajaxice.core.js') 35 | return '' % url 36 | -------------------------------------------------------------------------------- /dajaxice/tests/__init__.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | from django.conf import settings 4 | 5 | from dajaxice.core import DajaxiceConfig 6 | from dajaxice.core.Dajaxice import DajaxiceModule, DajaxiceFunction, Dajaxice 7 | from dajaxice.exceptions import FunctionNotCallableError 8 | 9 | 10 | class DajaxiceModuleTest(TestCase): 11 | 12 | def setUp(self): 13 | self.module = DajaxiceModule() 14 | 15 | def test_constructor(self): 16 | self.assertEqual(self.module.functions, {}) 17 | self.assertEqual(self.module.submodules, {}) 18 | 19 | def test_add_function(self): 20 | function = lambda x: x 21 | 22 | self.module.add('test', function) 23 | self.assertEqual(self.module.functions, {'test': function}) 24 | self.assertEqual(self.module.submodules, {}) 25 | 26 | self.module.add('foo.bar', function) 27 | self.assertEqual(self.module.functions, {'test': function}) 28 | self.assertEqual(self.module.submodules.keys(), ['foo']) 29 | self.assertEqual(self.module.submodules['foo'].functions, {'bar': function}) 30 | 31 | 32 | class DajaxiceFunctionTest(TestCase): 33 | 34 | def test_constructor(self): 35 | 36 | class CalledEception(Exception): 37 | pass 38 | 39 | def callback(): 40 | raise CalledEception 41 | 42 | function = DajaxiceFunction(callback, 'foo', 'POST') 43 | 44 | self.assertEqual(function.function, callback) 45 | self.assertEqual(function.name, 'foo') 46 | self.assertEqual(function.method, 'POST') 47 | self.assertRaises(CalledEception, function.call) 48 | 49 | 50 | class DajaxiceTest(TestCase): 51 | 52 | def setUp(self): 53 | self.dajaxice = Dajaxice() 54 | self.function = lambda x: x 55 | 56 | def test_constructor(self): 57 | self.assertEqual(self.dajaxice._registry, {}) 58 | 59 | def test_register(self): 60 | self.dajaxice.register(self.function, 'foo') 61 | self.assertTrue('foo' in self.dajaxice._registry) 62 | self.assertEqual(type(self.dajaxice._registry['foo']), DajaxiceFunction) 63 | 64 | def bar_function(): 65 | return 66 | 67 | self.dajaxice.register(bar_function) 68 | self.assertTrue('dajaxice.tests.bar_function' in self.dajaxice._registry) 69 | self.assertEqual(type(self.dajaxice._registry['dajaxice.tests.bar_function']), DajaxiceFunction) 70 | 71 | def test__is_callable(self): 72 | self.dajaxice.register(self.function, 'foo') 73 | self.dajaxice.register(self.function, 'bar', method='GET') 74 | 75 | self.assertTrue(self.dajaxice.is_callable('foo', 'POST')) 76 | self.assertTrue(self.dajaxice.is_callable('bar', 'GET')) 77 | self.assertFalse(self.dajaxice.is_callable('foo', 'GET')) 78 | self.assertFalse(self.dajaxice.is_callable('bar', 'POST')) 79 | self.assertFalse(self.dajaxice.is_callable('test', 'POST')) 80 | self.assertFalse(self.dajaxice.is_callable('test', 'GET')) 81 | 82 | def test_clean_method(self): 83 | self.assertEqual(self.dajaxice.clean_method('post'), 'POST') 84 | self.assertEqual(self.dajaxice.clean_method('get'), 'GET') 85 | self.assertEqual(self.dajaxice.clean_method('POST'), 'POST') 86 | self.assertEqual(self.dajaxice.clean_method('GET'), 'GET') 87 | self.assertEqual(self.dajaxice.clean_method('other'), 'POST') 88 | 89 | def test_modules(self): 90 | self.dajaxice.register(self.function, 'foo') 91 | self.dajaxice.register(self.function, 'bar') 92 | 93 | self.assertEqual(type(self.dajaxice.modules), DajaxiceModule) 94 | self.assertEqual(self.dajaxice.modules.functions.keys(), ['foo', 'bar']) 95 | 96 | 97 | class DajaxiceConfigTest(TestCase): 98 | 99 | def setUp(self): 100 | self.config = DajaxiceConfig() 101 | 102 | def test_defaults(self): 103 | self.assertTrue(self.config.DAJAXICE_XMLHTTPREQUEST_JS_IMPORT) 104 | self.assertTrue(self.config.DAJAXICE_JSON2_JS_IMPORT) 105 | self.assertEqual(self.config.DAJAXICE_EXCEPTION, 'DAJAXICE_EXCEPTION') 106 | self.assertEqual(self.config.DAJAXICE_MEDIA_PREFIX, 'dajaxice') 107 | 108 | dajaxice_url = r'^%s/' % self.config.DAJAXICE_MEDIA_PREFIX 109 | self.assertEqual(self.config.dajaxice_url, dajaxice_url) 110 | 111 | self.assertEqual(type(self.config.modules), DajaxiceModule) 112 | 113 | 114 | class DjangoIntegrationTest(TestCase): 115 | 116 | urls = 'dajaxice.tests.urls' 117 | 118 | def setUp(self): 119 | settings.INSTALLED_APPS += ('dajaxice.tests',) 120 | 121 | def test_calling_not_registered_function(self): 122 | self.failUnlessRaises(FunctionNotCallableError, self.client.post, '/dajaxice/dajaxice.tests.this_function_not_exist/') 123 | 124 | def test_calling_registered_function(self): 125 | response = self.client.post('/dajaxice/dajaxice.tests.test_foo/') 126 | 127 | self.failUnlessEqual(response.status_code, 200) 128 | self.failUnlessEqual(response.content, '{"foo": "bar"}') 129 | 130 | def test_calling_registered_function_with_params(self): 131 | 132 | response = self.client.post('/dajaxice/dajaxice.tests.test_foo_with_params/', {'argv': '{"param1":"value1"}'}) 133 | 134 | self.failUnlessEqual(response.status_code, 200) 135 | self.failUnlessEqual(response.content, '{"param1": "value1"}') 136 | 137 | def test_bad_function(self): 138 | 139 | response = self.client.post('/dajaxice/dajaxice.tests.test_ajax_exception/') 140 | self.failUnlessEqual(response.status_code, 200) 141 | self.failUnlessEqual(response.content, "DAJAXICE_EXCEPTION") 142 | 143 | def test_get_register(self): 144 | 145 | response = self.client.get('/dajaxice/dajaxice.tests.test_get_register/') 146 | 147 | self.failUnlessEqual(response.status_code, 200) 148 | self.failUnlessEqual(response.content, '{"foo": "user"}') 149 | 150 | def test_get_custom_name_register(self): 151 | 152 | response = self.client.get('/dajaxice/get_user_data/') 153 | 154 | self.failUnlessEqual(response.status_code, 200) 155 | self.failUnlessEqual(response.content, '{"bar": "user"}') 156 | 157 | def test_multi_register(self): 158 | 159 | response = self.client.get('/dajaxice/get_multi/') 160 | self.failUnlessEqual(response.status_code, 200) 161 | self.failUnlessEqual(response.content, '{"foo": "multi"}') 162 | 163 | response = self.client.post('/dajaxice/post_multi/') 164 | self.failUnlessEqual(response.status_code, 200) 165 | self.failUnlessEqual(response.content, '{"foo": "multi"}') 166 | -------------------------------------------------------------------------------- /dajaxice/tests/ajax.py: -------------------------------------------------------------------------------- 1 | import json 2 | from dajaxice.decorators import dajaxice_register 3 | 4 | 5 | @dajaxice_register 6 | def test_registered_function(request): 7 | return "" 8 | 9 | 10 | @dajaxice_register 11 | def test_string(request): 12 | return json.dumps({'string': 'hello world'}) 13 | 14 | 15 | @dajaxice_register 16 | def test_ajax_exception(request): 17 | raise Exception() 18 | 19 | 20 | @dajaxice_register 21 | def test_foo(request): 22 | return json.dumps({'foo': 'bar'}) 23 | 24 | 25 | @dajaxice_register 26 | def test_foo_with_params(request, param1): 27 | return json.dumps({'param1': param1}) 28 | 29 | 30 | @dajaxice_register(method='GET') 31 | def test_get_register(request): 32 | return json.dumps({'foo': 'user'}) 33 | 34 | 35 | @dajaxice_register(method='GET', name="get_user_data") 36 | def test_get_with_name_register(request): 37 | return json.dumps({'bar': 'user'}) 38 | 39 | 40 | @dajaxice_register(method='GET', name="get_multi") 41 | @dajaxice_register(name="post_multi") 42 | def test_multi_register(request): 43 | return json.dumps({'foo': 'multi'}) 44 | -------------------------------------------------------------------------------- /dajaxice/tests/requirements.txt: -------------------------------------------------------------------------------- 1 | Django 2 | -------------------------------------------------------------------------------- /dajaxice/tests/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import * 2 | 3 | from dajaxice.core import dajaxice_autodiscover, dajaxice_config 4 | 5 | dajaxice_autodiscover() 6 | 7 | urlpatterns = patterns('', 8 | #Dajaxice URLS 9 | url(dajaxice_config.dajaxice_url, include('dajaxice.urls')), 10 | ) 11 | -------------------------------------------------------------------------------- /dajaxice/urls.py: -------------------------------------------------------------------------------- 1 | try: 2 | from django.conf.urls import patterns, url 3 | except ImportError: 4 | from django.conf.urls.defaults import patterns, url 5 | 6 | from .views import DajaxiceRequest 7 | 8 | urlpatterns = patterns('dajaxice.views', 9 | url(r'^(.+)/$', DajaxiceRequest.as_view(), name='dajaxice-call-endpoint'), 10 | url(r'', DajaxiceRequest.as_view(), name='dajaxice-endpoint'), 11 | ) 12 | -------------------------------------------------------------------------------- /dajaxice/utils.py: -------------------------------------------------------------------------------- 1 | from django.http import QueryDict 2 | 3 | 4 | def deserialize_form(data): 5 | """ 6 | Create a new QueryDict from a serialized form. 7 | """ 8 | return QueryDict(query_string=unicode(data).encode('utf-8')) 9 | -------------------------------------------------------------------------------- /dajaxice/views.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import django 3 | from django.conf import settings 4 | import json 5 | from django.views.generic.base import View 6 | from django.http import HttpResponse, Http404 7 | 8 | from dajaxice.exceptions import FunctionNotCallableError 9 | from dajaxice.core import dajaxice_functions, dajaxice_config 10 | 11 | log = logging.getLogger('dajaxice') 12 | 13 | 14 | def safe_dict(d): 15 | """ 16 | Recursively clone json structure with UTF-8 dictionary keys 17 | http://www.gossamer-threads.com/lists/python/bugs/684379 18 | """ 19 | if isinstance(d, dict): 20 | return dict([(k.encode('utf-8'), safe_dict(v)) for k, v in d.iteritems()]) 21 | elif isinstance(d, list): 22 | return [safe_dict(x) for x in d] 23 | else: 24 | return d 25 | 26 | 27 | class DajaxiceRequest(View): 28 | """ Handle all the dajaxice xhr requests. """ 29 | 30 | def dispatch(self, request, name=None): 31 | 32 | if not name: 33 | raise Http404 34 | 35 | # Check if the function is callable 36 | if dajaxice_functions.is_callable(name, request.method): 37 | 38 | function = dajaxice_functions.get(name) 39 | data = getattr(request, function.method).get('argv', '') 40 | 41 | # Clean the argv 42 | if data != 'undefined': 43 | try: 44 | data = safe_dict(json.loads(data)) 45 | except Exception: 46 | data = {} 47 | else: 48 | data = {} 49 | 50 | # Call the function. If something goes wrong, handle the Exception 51 | try: 52 | response = function.call(request, **data) 53 | except Exception: 54 | if settings.DEBUG: 55 | raise 56 | response = dajaxice_config.DAJAXICE_EXCEPTION 57 | if django.get_version() >= '1.7': 58 | return HttpResponse(response, content_type="application/x-json") 59 | else: 60 | return HttpResponse(response, mimetype="application/x-json") 61 | else: 62 | raise FunctionNotCallableError(name) 63 | -------------------------------------------------------------------------------- /example/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/example/1.png -------------------------------------------------------------------------------- /example/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/example/2.png -------------------------------------------------------------------------------- /example/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/example/3.png -------------------------------------------------------------------------------- /example/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/example/4.png -------------------------------------------------------------------------------- /example/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/example/5.png -------------------------------------------------------------------------------- /example/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/example/6.png -------------------------------------------------------------------------------- /giscube/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube/__init__.py -------------------------------------------------------------------------------- /giscube/config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | #get the current directory 4 | current_dir = os.getcwd() 5 | 6 | STATIC_ROOT = '' 7 | STATIC_URL = '/static/' 8 | MEDIA_ROOT = '{0}/giscube_app/static/'.format(current_dir) 9 | MEDIA_URL = 'uploaded_files/' 10 | #BASE_DIR = '{0}/giscube_app/static/'.format(current_dir) #used for database -------------------------------------------------------------------------------- /giscube/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for giscube project. 3 | 4 | For more information on this file, see 5 | https://docs.djangoproject.com/en/1.6/topics/settings/ 6 | 7 | For the full list of settings and their values, see 8 | https://docs.djangoproject.com/en/1.6/ref/settings/ 9 | """ 10 | 11 | import os 12 | from config import STATIC_URL, MEDIA_ROOT, MEDIA_URL 13 | 14 | # SECURITY WARNING: keep the secret key used in production secret! 15 | SECRET_KEY = 'x(b%i4y0c*6ht(g=yo@4@@s%u06!h74_mt=i=-pt%s*yf9xc32' 16 | 17 | # SECURITY WARNING: don't run with debug turned on in production! 18 | DEBUG = True 19 | 20 | TEMPLATE_DEBUG = True 21 | 22 | ALLOWED_HOSTS = [] 23 | 24 | # Application definition 25 | INSTALLED_APPS = ( 26 | #'django.contrib.admin', 27 | #'django.contrib.auth', 28 | #'django.contrib.contenttypes', 29 | #'django.contrib.sessions', 30 | #'django.contrib.messages', 31 | 'django.contrib.staticfiles', 32 | 'giscube_app', 33 | 'dajaxice', 34 | ) 35 | 36 | MIDDLEWARE_CLASSES = ( 37 | 'django.contrib.sessions.middleware.SessionMiddleware', 38 | 'django.middleware.common.CommonMiddleware', 39 | 'django.middleware.csrf.CsrfViewMiddleware', 40 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 41 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 42 | 'django.contrib.messages.middleware.MessageMiddleware', 43 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 44 | ) 45 | 46 | TEMPLATE_LOADERS = ( 47 | 'django.template.loaders.filesystem.Loader', 48 | 'django.template.loaders.app_directories.Loader', 49 | 'django.template.loaders.eggs.Loader', 50 | ) 51 | 52 | TEMPLATE_CONTEXT_PROCESSORS = ( 53 | 'django.contrib.auth.context_processors.auth', 54 | 'django.core.context_processors.debug', 55 | 'django.core.context_processors.i18n', 56 | 'django.core.context_processors.media', 57 | 'django.core.context_processors.static', 58 | 'django.core.context_processors.request', 59 | 'django.contrib.messages.context_processors.messages' 60 | ) 61 | 62 | STATICFILES_FINDERS = ( 63 | 'django.contrib.staticfiles.finders.FileSystemFinder', 64 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 65 | 'dajaxice.finders.DajaxiceFinder', 66 | ) 67 | 68 | ROOT_URLCONF = 'giscube.urls' 69 | 70 | WSGI_APPLICATION = 'giscube.wsgi.application' 71 | 72 | LANGUAGE_CODE = 'en-us' 73 | 74 | TIME_ZONE = 'America/Los_Angeles' 75 | 76 | USE_I18N = True 77 | 78 | USE_L10N = True 79 | 80 | USE_TZ = True 81 | 82 | DATABASES = { 83 | 'default': { 84 | 'ENGINE': 'django.db.backends.sqlite3', 85 | 'NAME': os.path.join(MEDIA_ROOT, 'db.sqlite3'), 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /giscube/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, include, url 2 | from django.conf import settings 3 | from django.conf.urls.static import static 4 | from django.contrib.staticfiles.urls import staticfiles_urlpatterns 5 | from dajaxice.core import dajaxice_autodiscover, dajaxice_config 6 | dajaxice_autodiscover() 7 | 8 | urlpatterns = patterns('', 9 | url(r'^', include('giscube_app.urls')), 10 | url(r''+dajaxice_config.dajaxice_url, include('dajaxice.urls')), 11 | ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 12 | 13 | urlpatterns += staticfiles_urlpatterns() -------------------------------------------------------------------------------- /giscube/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for giscube project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "giscube.settings") 12 | 13 | from django.core.wsgi import get_wsgi_application 14 | application = get_wsgi_application() 15 | -------------------------------------------------------------------------------- /giscube_app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/__init__.py -------------------------------------------------------------------------------- /giscube_app/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | class DocumentForm(forms.Form): 4 | docfile = forms.FileField( 5 | #label='Select a file', 6 | #help_text='max. 42 megabytes' 7 | ) 8 | -------------------------------------------------------------------------------- /giscube_app/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from giscube.config import MEDIA_URL 3 | 4 | class Document(models.Model): 5 | docfile = models.FileField(upload_to=MEDIA_URL) -------------------------------------------------------------------------------- /giscube_app/scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/scripts/__init__.py -------------------------------------------------------------------------------- /giscube_app/scripts/clip_geotiff_by_shp.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def clip_geotiff_by_shp(selected_geotiff, selected_shapefile, clipped_geotiff_name): 4 | string = "gdalwarp -cutline {0} -crop_to_cutline {1} {2}".format(selected_shapefile, selected_geotiff, clipped_geotiff_name) 5 | os.system(string) -------------------------------------------------------------------------------- /giscube_app/scripts/data_management.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def change_geotiff_resolution(selected_geotiff, geotiff_new_x_res, geotiff_new_y_res, geotiff_new_resolution_name): 5 | string = "gdalwarp -tr {0} {1} {2} {3}".format(geotiff_new_x_res, geotiff_new_y_res, selected_geotiff, geotiff_new_resolution_name) 6 | os.system(string) 7 | 8 | def color_table_on_geotiff(selected_geotiff, selected_color_table, colored_geotiff_name): 9 | string = 'gdaldem color-relief {0} {1} {2} -alpha -of GTiff'.format(selected_geotiff, selected_color_table, colored_geotiff_name) 10 | os.system(string) -------------------------------------------------------------------------------- /giscube_app/scripts/extract_shp_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ''' 4 | Project: Geothon (https://github.com/MBoustani/Geothon) 5 | File: Vector/export_shp_att_csv.py 6 | Description: This code exports Shapefile attribute table to csv file 7 | Author: Maziyar Boustani (github.com/MBoustani) 8 | ''' 9 | import csv 10 | 11 | try: 12 | import ogr 13 | except ImportError: 14 | from osgeo import ogr 15 | 16 | def extract_shp_table(shp_file_name, csv_file_name): 17 | #set the driver to ESRI Shapefiel 18 | driver = ogr.GetDriverByName('ESRI Shapefile') 19 | 20 | #open shapefile 21 | shp_datasource = driver.Open(shp_file_name) 22 | 23 | #get shapefile layer 24 | layer = shp_datasource.GetLayerByIndex(0) 25 | 26 | #get shapefile layer definition 27 | layer_defn = layer.GetLayerDefn() 28 | 29 | #get number of fields(columns) from shapefile attribute table 30 | num_field_col = layer_defn.GetFieldCount() 31 | 32 | #create csv file to store shapefile attribute table 33 | with open(csv_file_name, 'wb') as csv_file: 34 | writer = csv.writer(csv_file) 35 | #store field header 36 | field_name = [] 37 | for field in range(num_field_col): 38 | field_name.append(layer_defn.GetFieldDefn(field).GetName()) 39 | writer.writerow(field_name) 40 | 41 | #store attribute from each feature 42 | num_feature = layer.GetFeatureCount() 43 | for each in range(num_feature): 44 | feautre = layer.GetFeature(each) 45 | feautre_name = [] 46 | for i in range(num_field_col): 47 | feautre_name.append(feautre.GetFieldAsString(i)) 48 | writer.writerow(feautre_name) -------------------------------------------------------------------------------- /giscube_app/scripts/gtif_to_tile.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | from giscube.config import MEDIA_ROOT, MEDIA_URL 4 | import subprocess 5 | 6 | def create_gtif(gtif): 7 | UPLOADED_FILE_DIR = '{0}{1}'.format(MEDIA_ROOT, MEDIA_URL) 8 | gtif_path = UPLOADED_FILE_DIR + gtif 9 | gtif_folder = gtif.split(".tif")[0] 10 | string = "gdal2tiles.py {0} {1}".format(gtif_path, gtif_folder) 11 | subprocess.Popen(["gdal2tiles.py","{0}".format(gtif_path),"{0}".format(gtif_folder)]) 12 | 13 | return gtif_folder -------------------------------------------------------------------------------- /giscube_app/scripts/metadata.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | try: 4 | from osgeo import gdal 5 | from osgeo import osr 6 | except ImportError: 7 | import gdal 8 | import osr 9 | try: 10 | from osgeo import ogr 11 | except ImportError: 12 | import ogr 13 | 14 | from netCDF4 import Dataset 15 | import numpy as np 16 | import urllib2 17 | import json 18 | 19 | def get_nc_data(nc_file, latitude_var, longitude_var, time_var, value_var, selected_time_index): 20 | print nc_file 21 | nc_dataset = open_file(nc_file) 22 | if nc_dataset: 23 | lat = nc_dataset.variables[latitude_var] 24 | lon = nc_dataset.variables[longitude_var] 25 | time = nc_dataset.variables[time_var] 26 | value = nc_dataset.variables[value_var] 27 | 28 | lat_dim = lat.dimensions 29 | lon_dim = lon.dimensions 30 | time_dim = time.dimensions 31 | value_dim = value.dimensions 32 | 33 | lat_shape = lat.shape 34 | lon_shape = lon.shape 35 | time_shape = time.shape 36 | value_shape = value.shape 37 | 38 | print 'Latitude shape: {0}'.format(lat_shape) 39 | print 'Longitude shape: {0}'.format(lon_shape) 40 | print 'Time shape: {0}'.format(time_shape) 41 | print 'Value shape: {0}'.format(value_shape) 42 | 43 | print "Getting dimensions info" 44 | dims_info = {} 45 | for i, each in enumerate(lat_dim): 46 | dims_info[each] = lat_shape[i] 47 | 48 | for i, each in enumerate(lon_dim): 49 | dims_info[each] = lon_shape[i] 50 | 51 | for i, each in enumerate(time_dim): 52 | dims_info[each] = time_shape[i] 53 | 54 | print "Slicing vlaues" 55 | slices = () 56 | for dim in value_dim: 57 | if dim in dims_info: 58 | if dim in time_dim: 59 | slices += (slice(selected_time_index,selected_time_index+1),) 60 | else: 61 | slices += (slice(0,dims_info[dim]+1),) 62 | else: 63 | slices += (slice(0,1),) 64 | print "Values sliced" 65 | print np.squeeze(value[slices]).shape 66 | return np.squeeze(value[slices]) 67 | 68 | def open_file(file_path): 69 | try: 70 | nc_file = Dataset(file_path, mode='r') 71 | if not nc_file: 72 | raise "File cannot be opened" 73 | return nc_file 74 | except: 75 | raise "File cannot be opened" 76 | sys.exit() 77 | 78 | def get_variables(nc_file): 79 | if nc_file: 80 | return [variable.encode() for variable in nc_file.variables.keys()] 81 | 82 | 83 | def get_file_name(file_path): 84 | if file_path: 85 | return file_path 86 | 87 | 88 | def variables_info(nc_file, all_variables): 89 | variables_info = [] 90 | for value in all_variables: 91 | variable = nc_file.variables[value] 92 | each_variable = {} 93 | each_variable[value] = {} 94 | each_variable[value]['dimensions'] = variable.dimensions 95 | for att in variable.ncattrs(): 96 | each_variable[value][att] = variable.getncattr(att) 97 | variables_info.append(each_variable) 98 | 99 | return variables_info 100 | 101 | 102 | def get_nc_metadata(file_path): 103 | try: 104 | nc_metadata = urllib2.urlopen("http://127.0.0.1:18080/uploaded_files/{0}/?output=json&traverse".format(file_path)).read() 105 | dic = json.loads(nc_metadata) 106 | nc_variables = [] 107 | for each in dic['leaves']: 108 | nc_variables.append(each['name']) 109 | return {'file_name':file_path, 'nc_metadata':nc_metadata, 'nc_variables':nc_variables} 110 | except: 111 | return None 112 | 113 | 114 | def get_hdf_metadata(file_path): 115 | try: 116 | hdf_metadata = urllib2.urlopen("http://127.0.0.1:18080/uploaded_files/{0}/?output=json&traverse".format(file_path)).read() 117 | return {'file_name':file_path, 'hdf_metadata':hdf_metadata} 118 | except: 119 | return None 120 | 121 | #####shp_name_info.py 122 | 123 | def open_shp_file(file_path): 124 | try: 125 | vector_file = ogr.Open(file_path) 126 | if not vector_file: 127 | raise "File cannot be opened" 128 | return vector_file 129 | except: 130 | raise "File cannot be opened" 131 | sys.exit() 132 | 133 | def get_shp_name(vector_file): 134 | try: 135 | file_name = vector_file.GetName() 136 | return file_name 137 | except: 138 | return None 139 | 140 | def get_shp_format(vector_file): 141 | try: 142 | file_format = vector_file.GetDriver().GetName() 143 | return file_format 144 | except: 145 | return None 146 | 147 | def get_shp_number_of_layers(vector_file): 148 | try: 149 | number_of_layers = vector_file.GetLayerCount() 150 | return number_of_layers 151 | except: 152 | return None 153 | 154 | def get_shp_layer(vector_file, layer_index): 155 | try: 156 | layer = vector_file.GetLayerByIndex(layer_index) 157 | return layer 158 | except: 159 | return None 160 | 161 | def get_shp_layer_name(layer_file): 162 | try: 163 | layer_name = layer_file.GetName() 164 | return layer_name 165 | except: 166 | return None 167 | 168 | def get_shp_number_of_feature(layer_file): 169 | try: 170 | number_of_feature = layer_file.GetFeatureCount() 171 | return number_of_feature 172 | except: 173 | return None 174 | 175 | def get_shp_layer_type(layer_file): 176 | try: 177 | geom_type_index = layer_file.GetLayerDefn().GetGeomType() 178 | layer_type = ogr.GeometryTypeToName(geom_type_index) 179 | return layer_type 180 | except: 181 | return None 182 | 183 | def get_shp_layer_spatial_reference(layer_file): 184 | try: 185 | layer_spatial_reference = layer_file.GetSpatialRef().ExportToPrettyWkt() 186 | return layer_spatial_reference 187 | except: 188 | return None 189 | 190 | def get_shp_layer_extend(layer_file): 191 | try: 192 | layer_extend = layer_file.GetExtent() 193 | return layer_extend 194 | except: 195 | return None 196 | 197 | 198 | def run_shp_info(file_path): 199 | layers = [] 200 | vector_file = open_shp_file(file_path) #To open vector file 201 | file_name = get_shp_name(vector_file) #To print file name 202 | file_format = get_shp_format(vector_file) #To print file format 203 | file_number_of_layers = get_shp_number_of_layers(vector_file) #To print number of layer/s 204 | for layer_index in range(file_number_of_layers): 205 | layer = {} 206 | layer_file = get_shp_layer(vector_file, layer_index) 207 | layer['layer file'] = layer_file 208 | layer_name = get_shp_layer_name(layer_file) 209 | layer['layer name'] = layer_name 210 | number_of_feature = get_shp_number_of_feature(layer_file) 211 | layer['number of feature'] = number_of_feature 212 | layer_type = get_shp_layer_type(layer_file) 213 | layer['layer type'] = layer_type 214 | layer_spatial_reference = get_shp_layer_spatial_reference(layer_file) 215 | layer['layer spatial reference'] = layer_spatial_reference 216 | layer_extend = get_shp_layer_extend(layer_file) 217 | layer['layer extend'] = layer_extend 218 | layers.append(layer) 219 | 220 | return {'file_name':file_name, 'file_format':file_format , 'num_layer':str(file_number_of_layers),\ 221 | 'layer_name':layer['layer name'], 'number_of_feature':layer['number of feature'],\ 222 | 'layer_type':layer['layer type'], 'layer_spatial_reference':layer['layer spatial reference'],\ 223 | 'layer_extend':layer['layer extend']} 224 | 225 | 226 | 227 | #####tif_name_info.py 228 | 229 | def open_tif(file_path): 230 | try: 231 | raster_file = gdal.Open(file_path) 232 | if not raster_file: 233 | raise "File cannot be opened" 234 | return raster_file 235 | except: 236 | raise "File cannot be opened" 237 | sys.exit() 238 | 239 | def get_tif_name(raster_file): 240 | try: 241 | file_name = raster_file.GetDescription() 242 | return file_name 243 | except: 244 | return None 245 | 246 | def get_tif_format(raster_file): 247 | try: 248 | file_format = raster_file.GetDriver().LongName 249 | return file_format 250 | except: 251 | return None 252 | 253 | def get_raster_number_of_band(raster_file): 254 | try: 255 | raster_number_of_band = raster_file.RasterCount 256 | return raster_number_of_band 257 | except: 258 | return None 259 | 260 | def get_raster_x_y_size(raster_file): 261 | try: 262 | raster_x_y_size = [raster_file.RasterXSize, raster_file.RasterYSize] 263 | return raster_x_y_size 264 | except: 265 | return None 266 | 267 | def get_raster_projection(raster_file): 268 | try: 269 | raster_projection = raster_file.GetProjectionRef() 270 | hSRS = osr.SpatialReference() 271 | hSRS.ImportFromWkt(raster_projection ) 272 | pszPrettyWkt = hSRS.ExportToPrettyWkt(False) 273 | return pszPrettyWkt 274 | except: 275 | return None 276 | 277 | def get_raster_geotransform(raster_file): 278 | try: 279 | raster_geotransform = raster_file.GetGeoTransform() 280 | return raster_geotransform 281 | except: 282 | return None 283 | 284 | def get_raster_origin(raster_geotransform): 285 | try: 286 | raster_origin = (raster_geotransform[0], raster_geotransform[3]) 287 | return raster_origin 288 | except Exception: 289 | return None 290 | 291 | def get_raster_pixle_size(raster_geotransform): 292 | try: 293 | raster_pixle_size = (raster_geotransform[1], raster_geotransform[5]) 294 | return raster_pixle_size 295 | except: 296 | return None 297 | 298 | 299 | 300 | def run_tif_info(file_path): 301 | layers = [] 302 | raster_file = open_tif(file_path) #To open raster file 303 | file_name = get_tif_name(raster_file) #To print file name 304 | file_format = get_tif_format(raster_file) #To print file format 305 | raster_number_of_band = get_raster_number_of_band(raster_file) 306 | raster_x_y_size = get_raster_x_y_size(raster_file) 307 | raster_projection = get_raster_projection(raster_file) 308 | raster_geotransform = get_raster_geotransform(raster_file) 309 | raster_origin = get_raster_origin(raster_geotransform) 310 | raster_pixle_size = get_raster_pixle_size(raster_geotransform) 311 | 312 | return {'file_name':file_name, 'file_format':file_format , 'num_band':str(raster_number_of_band),\ 313 | 'raster_x_y_size':raster_x_y_size, 'raster_projection':raster_projection,\ 314 | 'raster_geotransform':raster_geotransform, 'raster_origin':raster_origin,\ 315 | 'raster_pixle_size':raster_pixle_size} -------------------------------------------------------------------------------- /giscube_app/scripts/open_file.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | try: 4 | from osgeo import ogr 5 | except ImportError: 6 | import ogr 7 | 8 | try: 9 | from osgeo import gdal 10 | from osgeo import osr 11 | except ImportError: 12 | import gdal 13 | import osr 14 | 15 | 16 | def open_shp_file(file_path): 17 | try: 18 | vector_file = ogr.Open(file_path) 19 | return vector_file 20 | except: 21 | return False 22 | 23 | 24 | def open_tif_file(file_path): 25 | try: 26 | raster_file = gdal.Open(file_path) 27 | return raster_file 28 | except: 29 | return False -------------------------------------------------------------------------------- /giscube_app/scripts/opendap.py: -------------------------------------------------------------------------------- 1 | from pydap.client import open_url 2 | from netcdftime import utime 3 | import numpy as np 4 | import urllib 5 | 6 | from giscube.config import MEDIA_ROOT, MEDIA_URL 7 | 8 | def opendap_metadata(opendap_url): 9 | response = urllib.urlopen(opendap_url + ".das") 10 | return response.read() 11 | 12 | def load(url, frm, name): 13 | if url.split(".")[-1] != "gz": 14 | url = url + "gz" 15 | if frm == "ASCII": 16 | urllib.urlretrieve ("{0}.ascii".format(url), "{0}{1}".format(MEDIA_ROOT + MEDIA_URL, "{0}.ascii".format(name))) 17 | elif frm == "nc3": 18 | urllib.urlretrieve ("{0}.nc".format(url), "{0}{1}".format(MEDIA_ROOT + MEDIA_URL, "{0}.nc".format(name))) 19 | elif frm == "nc4": 20 | urllib.urlretrieve ("{0}.dap.nc4".format(url), "{0}{1}".format(MEDIA_ROOT + MEDIA_URL, "{0}.nc".format(name))) -------------------------------------------------------------------------------- /giscube_app/scripts/spatial_analysis.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | try: 4 | import ogr 5 | except ImportError: 6 | from osgeo import ogr 7 | 8 | try: 9 | import osr 10 | except ImportError: 11 | from osgeo import osr 12 | 13 | 14 | def buffer_shapefile(selected_shp, buffer_shp_buffer_range, buffer_shp_out_name, buffer_shp_out_layername): 15 | if selected_shp.split(".")[-1] != "shp": 16 | selected_shp = selected_shp + ".shp" 17 | try: 18 | buffer_shp_buffer_range = float(buffer_shp_buffer_range) 19 | driver = ogr.GetDriverByName('ESRI Shapefile') 20 | in_shp_datasource = driver.Open(selected_shp) 21 | in_layer = in_shp_datasource.GetLayer() 22 | in_srs = in_layer.GetSpatialRef() 23 | num_feature = in_layer.GetFeatureCount() 24 | out_shp_datasource = driver.CreateDataSource(buffer_shp_out_name) 25 | srs = osr.SpatialReference() 26 | srs.ImportFromEPSG(4326) 27 | print in_srs 28 | print srs 29 | out_layer = out_shp_datasource.CreateLayer(buffer_shp_out_layername, in_srs, ogr.wkbMultiPolygon) 30 | for each in range(num_feature): 31 | in_feature = in_layer.GetFeature(each) 32 | in_geom = in_feature.GetGeometryRef() 33 | bufer_geom = in_geom.Buffer(buffer_shp_buffer_range) 34 | out_feature = ogr.Feature(out_layer.GetLayerDefn()) 35 | out_feature.SetGeometry(bufer_geom) 36 | out_layer.CreateFeature(out_feature) 37 | return "Done." 38 | except: 39 | return "Someting went wrong" 40 | 41 | 42 | def find_point_inside_feature(selected_vector, point_inside_shapefile_lat, point_inside_shapefile_lon): 43 | 44 | in_shp_datasource = ogr.Open("{0}.shp".format(selected_vector)) 45 | in_layer = in_shp_datasource.GetLayerByIndex(0) 46 | in_layer_defn = in_layer.GetLayerDefn() 47 | num_field_col = in_layer_defn.GetFieldCount() 48 | 49 | try: 50 | point = ogr.Geometry(ogr.wkbPoint) 51 | point.AddPoint(float(point_inside_shapefile_lon), float(point_inside_shapefile_lat)) 52 | except: 53 | print "cannot create point geometry" 54 | 55 | try: 56 | field_name = [] 57 | for field in range(num_field_col): 58 | field_name.append(in_layer_defn.GetFieldDefn(field).GetName()) 59 | except: 60 | print "Cannot read feature attribute information" 61 | 62 | feature_info = "Point is not in any feature." 63 | features_number = in_layer.GetFeatureCount() 64 | for i in range(features_number): 65 | in_shp_feature = in_layer.GetFeature(i) 66 | in_feature_geometry = in_shp_feature.GetGeometryRef() 67 | if point.Within(in_feature_geometry): 68 | field_count = in_shp_feature.GetFieldCount() 69 | feature_info = "" 70 | for field in range(field_count): 71 | feature_info += "

{0}:

{1}

".format(field_name[field], in_shp_feature.GetFieldAsString(field)) 72 | break 73 | 74 | return feature_info 75 | -------------------------------------------------------------------------------- /giscube_app/scripts/what_file.py: -------------------------------------------------------------------------------- 1 | try: 2 | from osgeo import gdal 3 | from osgeo import ogr 4 | except ImportError: 5 | import gdal 6 | import ogr 7 | 8 | from gdalconst import GA_ReadOnly 9 | 10 | 11 | 12 | def what_format(file_path): 13 | ''' 14 | Open either raster or vector file and return format of it 15 | ''' 16 | try: 17 | dataset = gdal.Open(file_path, GA_ReadOnly) 18 | driver_name = dataset.GetDriver().LongName 19 | return driver_name 20 | except: 21 | driver_name = "Format not found." 22 | 23 | try: 24 | dataset = ogr.Open(file_path) 25 | driver_name = dataset.GetDriver().GetName() 26 | print driver_name 27 | return driver_name 28 | except: 29 | driver_name = "Format not found." 30 | 31 | return driver_name -------------------------------------------------------------------------------- /giscube_app/static/css/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/css/.DS_Store -------------------------------------------------------------------------------- /giscube_app/static/css/bootstrap-glyphicons.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:'Glyphicons Halflings';src:url('../fonts/glyphiconshalflings-regular.eot');src:url('../fonts/glyphiconshalflings-regular.eot?#iefix') format('embedded-opentype'),url('../fonts/glyphiconshalflings-regular.woff') format('woff'),url('../fonts/glyphiconshalflings-regular.ttf') format('truetype'),url('../fonts/glyphiconshalflings-regular.svg#glyphicons_halflingsregular') format('svg')}.glyphicon:before{font-family:'Glyphicons Halflings';font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased}.glyphicon-glass:before{content:"\e001"}.glyphicon-music:before{content:"\e002"}.glyphicon-search:before{content:"\e003"}.glyphicon-envelope:before{content:"\2709"}.glyphicon-heart:before{content:"\e005"}.glyphicon-star:before{content:"\e006"}.glyphicon-star-empty:before{content:"\e007"}.glyphicon-user:before{content:"\e008"}.glyphicon-film:before{content:"\e009"}.glyphicon-th-large:before{content:"\e010"}.glyphicon-th:before{content:"\e011"}.glyphicon-th-list:before{content:"\e012"}.glyphicon-ok:before{content:"\e013"}.glyphicon-remove:before{content:"\e014"}.glyphicon-zoom-in:before{content:"\e015"}.glyphicon-zoom-out:before{content:"\e016"}.glyphicon-off:before{content:"\e017"}.glyphicon-signal:before{content:"\e018"}.glyphicon-cog:before{content:"\e019"}.glyphicon-trash:before{content:"\e020"}.glyphicon-home:before{content:"\e021"}.glyphicon-file:before{content:"\e022"}.glyphicon-time:before{content:"\e023"}.glyphicon-road:before{content:"\e024"}.glyphicon-download-alt:before{content:"\e025"}.glyphicon-download:before{content:"\e026"}.glyphicon-upload:before{content:"\e027"}.glyphicon-inbox:before{content:"\e028"}.glyphicon-play-circle:before{content:"\e029"}.glyphicon-repeat:before{content:"\e030"}.glyphicon-refresh:before{content:"\e031"}.glyphicon-list-alt:before{content:"\e032"}.glyphicon-lock:before{content:"\e033"}.glyphicon-flag:before{content:"\e034"}.glyphicon-headphones:before{content:"\e035"}.glyphicon-volume-off:before{content:"\e036"}.glyphicon-volume-down:before{content:"\e037"}.glyphicon-volume-up:before{content:"\e038"}.glyphicon-qrcode:before{content:"\e039"}.glyphicon-barcode:before{content:"\e040"}.glyphicon-tag:before{content:"\e041"}.glyphicon-tags:before{content:"\e042"}.glyphicon-book:before{content:"\e043"}.glyphicon-bookmark:before{content:"\e044"}.glyphicon-print:before{content:"\e045"}.glyphicon-camera:before{content:"\e046"}.glyphicon-font:before{content:"\e047"}.glyphicon-bold:before{content:"\e048"}.glyphicon-italic:before{content:"\e049"}.glyphicon-text-height:before{content:"\e050"}.glyphicon-text-width:before{content:"\e051"}.glyphicon-align-left:before{content:"\e052"}.glyphicon-align-center:before{content:"\e053"}.glyphicon-align-right:before{content:"\e054"}.glyphicon-align-justify:before{content:"\e055"}.glyphicon-list:before{content:"\e056"}.glyphicon-indent-left:before{content:"\e057"}.glyphicon-indent-right:before{content:"\e058"}.glyphicon-facetime-video:before{content:"\e059"}.glyphicon-picture:before{content:"\e060"}.glyphicon-pencil:before{content:"\270f"}.glyphicon-map-marker:before{content:"\e062"}.glyphicon-adjust:before{content:"\e063"}.glyphicon-tint:before{content:"\e064"}.glyphicon-edit:before{content:"\e065"}.glyphicon-share:before{content:"\e066"}.glyphicon-check:before{content:"\e067"}.glyphicon-move:before{content:"\e068"}.glyphicon-step-backward:before{content:"\e069"}.glyphicon-fast-backward:before{content:"\e070"}.glyphicon-backward:before{content:"\e071"}.glyphicon-play:before{content:"\e072"}.glyphicon-pause:before{content:"\e073"}.glyphicon-stop:before{content:"\e074"}.glyphicon-forward:before{content:"\e075"}.glyphicon-fast-forward:before{content:"\e076"}.glyphicon-step-forward:before{content:"\e077"}.glyphicon-eject:before{content:"\e078"}.glyphicon-chevron-left:before{content:"\e079"}.glyphicon-chevron-right:before{content:"\e080"}.glyphicon-plus-sign:before{content:"\e081"}.glyphicon-minus-sign:before{content:"\e082"}.glyphicon-remove-sign:before{content:"\e083"}.glyphicon-ok-sign:before{content:"\e084"}.glyphicon-question-sign:before{content:"\e085"}.glyphicon-info-sign:before{content:"\e086"}.glyphicon-screenshot:before{content:"\e087"}.glyphicon-remove-circle:before{content:"\e088"}.glyphicon-ok-circle:before{content:"\e089"}.glyphicon-ban-circle:before{content:"\e090"}.glyphicon-arrow-left:before{content:"\e091"}.glyphicon-arrow-right:before{content:"\e092"}.glyphicon-arrow-up:before{content:"\e093"}.glyphicon-arrow-down:before{content:"\e094"}.glyphicon-share-alt:before{content:"\e095"}.glyphicon-resize-full:before{content:"\e096"}.glyphicon-resize-small:before{content:"\e097"}.glyphicon-plus:before{content:"\002b"}.glyphicon-minus:before{content:"\2212"}.glyphicon-asterisk:before{content:"\002a"}.glyphicon-exclamation-sign:before{content:"\e101"}.glyphicon-gift:before{content:"\e102"}.glyphicon-leaf:before{content:"\e103"}.glyphicon-fire:before{content:"\e104"}.glyphicon-eye-open:before{content:"\e105"}.glyphicon-eye-close:before{content:"\e106"}.glyphicon-warning-sign:before{content:"\e107"}.glyphicon-plane:before{content:"\e108"}.glyphicon-calendar:before{content:"\e109"}.glyphicon-random:before{content:"\e110"}.glyphicon-comment:before{content:"\e111"}.glyphicon-magnet:before{content:"\e112"}.glyphicon-chevron-up:before{content:"\e113"}.glyphicon-chevron-down:before{content:"\e114"}.glyphicon-retweet:before{content:"\e115"}.glyphicon-shopping-cart:before{content:"\e116"}.glyphicon-folder-close:before{content:"\e117"}.glyphicon-folder-open:before{content:"\e118"}.glyphicon-resize-vertical:before{content:"\e119"}.glyphicon-resize-horizontal:before{content:"\e120"}.glyphicon-hdd:before{content:"\e121"}.glyphicon-bullhorn:before{content:"\e122"}.glyphicon-bell:before{content:"\e123"}.glyphicon-certificate:before{content:"\e124"}.glyphicon-thumbs-up:before{content:"\e125"}.glyphicon-thumbs-down:before{content:"\e126"}.glyphicon-hand-right:before{content:"\e127"}.glyphicon-hand-left:before{content:"\e128"}.glyphicon-hand-up:before{content:"\e129"}.glyphicon-hand-down:before{content:"\e130"}.glyphicon-circle-arrow-right:before{content:"\e131"}.glyphicon-circle-arrow-left:before{content:"\e132"}.glyphicon-circle-arrow-up:before{content:"\e133"}.glyphicon-circle-arrow-down:before{content:"\e134"}.glyphicon-globe:before{content:"\e135"}.glyphicon-wrench:before{content:"\e136"}.glyphicon-tasks:before{content:"\e137"}.glyphicon-filter:before{content:"\e138"}.glyphicon-briefcase:before{content:"\e139"}.glyphicon-fullscreen:before{content:"\e140"}.glyphicon-dashboard:before{content:"\e141"}.glyphicon-paperclip:before{content:"\e142"}.glyphicon-heart-empty:before{content:"\e143"}.glyphicon-link:before{content:"\e144"}.glyphicon-phone:before{content:"\e145"}.glyphicon-pushpin:before{content:"\e146"}.glyphicon-euro:before{content:"\20ac"}.glyphicon-usd:before{content:"\e148"}.glyphicon-gbp:before{content:"\e149"}.glyphicon-sort:before{content:"\e150"}.glyphicon-sort-by-alphabet:before{content:"\e151"}.glyphicon-sort-by-alphabet-alt:before{content:"\e152"}.glyphicon-sort-by-order:before{content:"\e153"}.glyphicon-sort-by-order-alt:before{content:"\e154"}.glyphicon-sort-by-attributes:before{content:"\e155"}.glyphicon-sort-by-attributes-alt:before{content:"\e156"}.glyphicon-unchecked:before{content:"\e157"}.glyphicon-expand:before{content:"\e158"}.glyphicon-collapse:before{content:"\e159"}.glyphicon-collapse-top:before{content:"\e160"} 2 | /* This beautiful CSS-File has been crafted with LESS (lesscss.org) and compiled by simpLESS (wearekiss.com/simpless) */ -------------------------------------------------------------------------------- /giscube_app/static/css/jquery.fileupload-ui.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | /* 3 | * jQuery File Upload UI Plugin CSS 8.8.5 4 | * https://github.com/blueimp/jQuery-File-Upload 5 | * 6 | * Copyright 2010, Sebastian Tschan 7 | * https://blueimp.net 8 | * 9 | * Licensed under the MIT license: 10 | * http://www.opensource.org/licenses/MIT 11 | */ 12 | 13 | .fileupload-buttonbar .btn, 14 | .fileupload-buttonbar .toggle { 15 | margin-bottom: 5px; 16 | } 17 | .progress-animated .progress-bar, 18 | .progress-animated .bar { 19 | background: url("../img/progressbar.gif") !important; 20 | filter: none; 21 | } 22 | .fileupload-loading { 23 | float: right; 24 | width: 32px; 25 | height: 32px; 26 | background: url("../img/loading.gif") center no-repeat; 27 | background-size: contain; 28 | display: none; 29 | } 30 | .fileupload-processing .fileupload-loading { 31 | display: block; 32 | } 33 | .files audio, 34 | .files video { 35 | max-width: 300px; 36 | } 37 | 38 | @media (max-width: 767px) { 39 | .fileupload-buttonbar .toggle, 40 | .files .toggle, 41 | .files .btn span { 42 | display: none; 43 | } 44 | .files .name { 45 | width: 80px; 46 | word-wrap: break-word; 47 | } 48 | .files audio, 49 | .files video { 50 | max-width: 80px; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /giscube_app/static/css/jquery.fileupload.css: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | /* 3 | * jQuery File Upload Plugin CSS 1.3.0 4 | * https://github.com/blueimp/jQuery-File-Upload 5 | * 6 | * Copyright 2013, Sebastian Tschan 7 | * https://blueimp.net 8 | * 9 | * Licensed under the MIT license: 10 | * http://www.opensource.org/licenses/MIT 11 | */ 12 | 13 | .fileinput-button { 14 | position: relative; 15 | overflow: hidden; 16 | } 17 | .fileinput-button input { 18 | position: absolute; 19 | top: 0; 20 | right: 0; 21 | margin: 0; 22 | opacity: 0; 23 | -ms-filter: 'alpha(opacity=0)'; 24 | font-size: 200px; 25 | direction: ltr; 26 | cursor: pointer; 27 | } 28 | 29 | /* Fixes for IE < 8 */ 30 | @media screen\9 { 31 | .fileinput-button input { 32 | filter: alpha(opacity=0); 33 | font-size: 100%; 34 | height: 100%; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /giscube_app/static/css/leaflet-0.6.4_leaflet.ie.css: -------------------------------------------------------------------------------- 1 | .leaflet-vml-shape { 2 | width: 1px; 3 | height: 1px; 4 | } 5 | .lvml { 6 | behavior: url(#default#VML); 7 | display: inline-block; 8 | position: absolute; 9 | } 10 | 11 | .leaflet-control { 12 | display: inline; 13 | } 14 | 15 | .leaflet-popup-tip { 16 | width: 21px; 17 | _width: 27px; 18 | margin: 0 auto; 19 | _margin-top: -3px; 20 | 21 | filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); 22 | -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; 23 | } 24 | .leaflet-popup-tip-container { 25 | margin-top: -1px; 26 | } 27 | .leaflet-popup-content-wrapper, .leaflet-popup-tip { 28 | border: 1px solid #999; 29 | } 30 | .leaflet-popup-content-wrapper { 31 | zoom: 1; 32 | } 33 | 34 | .leaflet-control-zoom, 35 | .leaflet-control-layers { 36 | border: 3px solid #999; 37 | } 38 | .leaflet-control-layers-toggle { 39 | } 40 | .leaflet-control-attribution, 41 | .leaflet-control-layers, 42 | .leaflet-control-scale-line { 43 | background: white; 44 | } 45 | .leaflet-zoom-box { 46 | filter: alpha(opacity=50); 47 | } 48 | .leaflet-control-attribution { 49 | border-top: 1px solid #bbb; 50 | border-left: 1px solid #bbb; 51 | } -------------------------------------------------------------------------------- /giscube_app/static/css/ol.css: -------------------------------------------------------------------------------- 1 | .ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:#95b9e6;background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px;padding:2px;position:absolute}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;padding:0 2px}.ol-unsupported{display:none}.ol-viewport .ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-control{position:absolute;background-color:#eee;background-color:rgba(255,255,255,.4);border-radius:4px;padding:2px}.ol-control:hover{background-color:rgba(255,255,255,.6)}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}@media print{.ol-control{display:none}}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:#7b98bc;background-color:rgba(0,60,136,.5);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-family:Arial;font-weight:400;font-size:1.2em}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:focus,.ol-control button:hover{text-decoration:none;background-color:#4c6079;background-color:rgba(0,60,136,.7)}.ol-zoom-extent button:after{content:"E"}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}button.ol-full-screen-false:after{content:"\2194"}button.ol-full-screen-true:after{content:"\00d7"}.ol-has-tooltip [role=tooltip]{position:absolute;clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px);padding:0;border:0;height:1px;width:1px;overflow:hidden;font-weight:400;font-size:14px;text-shadow:0 0 2px #fff}.ol-has-tooltip:focus [role=tooltip],.ol-has-tooltip:hover [role=tooltip]{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;clip:auto;padding:0 .4em;font-size:.8em;height:1.2em;width:auto;line-height:1.2em;z-index:1100;max-height:100px;white-space:nowrap;display:inline-block;background:#FFF;background:rgba(255,255,255,.6);color:#000;border:3px solid transparent;border-left-width:0;border-radius:0 4px 4px 0;bottom:.3em;left:2.2em}.ol-touch .ol-has-tooltip:focus [role=tooltip],.ol-touch .ol-has-tooltip:hover [role=tooltip]{display:none}.ol-zoom .ol-has-tooltip:focus [role=tooltip],.ol-zoom .ol-has-tooltip:hover [role=tooltip]{top:1.1em}.ol-attribution .ol-has-tooltip:focus [role=tooltip],.ol-attribution .ol-has-tooltip:hover [role=tooltip],.ol-full-screen .ol-has-tooltip:focus [role=tooltip],.ol-full-screen .ol-has-tooltip:hover [role=tooltip],.ol-rotate .ol-has-tooltip:focus [role=tooltip],.ol-rotate .ol-has-tooltip:hover [role=tooltip]{right:2.2em;left:auto;border-radius:4px 0 0 4px;border-left-width:3px;border-right-width:0}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em)}.ol-attribution ul{margin:0;padding:0 .5em;font-size:.7rem;line-height:1.375em;color:#000;text-shadow:0 0 2px #fff;max-width:calc(100% - 3.6em)}.ol-attribution li{display:inline;list-style:none;line-height:inherit}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em}.ol-attribution button,.ol-attribution ul{display:inline-block}.ol-attribution.ol-collapsed ul,.ol-attribution:not(.ol-collapsed) button:hover [role=tooltip]{display:none}.ol-attribution.ol-logo-only ul{display:block}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0;height:1.1em;line-height:1em}.ol-attribution.ol-logo-only{background:0 0;bottom:.4em;height:1.1em;line-height:1em}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-logo-only button,.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{position:absolute;top:4.5em;left:.5em;background:#eee;background:rgba(255,255,255,.4);border-radius:4px;outline:0;overflow:hidden;width:1.5675em;height:200px;padding:3px;margin:0}.ol-zoomslider-thumb{position:absolute;display:block;background:#7b98bc;background:rgba(0,60,136,.5);border-radius:2px;outline:0;overflow:hidden;cursor:pointer;font-size:1.14em;height:1em;width:1.375em;margin:3px;padding:0}.ol-touch .ol-zoomslider{top:5.5em;width:2.052em}.ol-touch .ol-zoomslider-thumb{width:1.8em}.ol-attribution,.ol-control button,.ol-has-tooltip [role=tooltip],.ol-scale-line-inner{font-family:'Lucida Grande',Verdana,Geneva,Lucida,Arial,Helvetica,sans-serif} -------------------------------------------------------------------------------- /giscube_app/static/css/side_menu.css: -------------------------------------------------------------------------------- 1 | .menu { 2 | width: 40%; 3 | height: 100%; 4 | position: fixed; 5 | background-color: #fff; 6 | -webkit-transition: all 1s; 7 | transition: all 1s; 8 | right: 0; 9 | overflow-y: auto; 10 | padding-bottom: 0px; 11 | z-index: 10; 12 | } 13 | 14 | .menu.closed { right: -40%; } 15 | 16 | #toggle { 17 | background-color: #000000; 18 | height: 100%; 19 | min-height: 100%; 20 | width: 0px; 21 | position: fixed; 22 | top: 0; 23 | bottom: 0; 24 | -webkit-transition: all .7s ease; 25 | transition: all .7s ease; 26 | } 27 | 28 | #toggle.closed { 29 | right:0px; 30 | top: 0; 31 | bottom: 0; 32 | left: 0; 33 | width: 60%; 34 | height: 100%; 35 | opacity: .9; 36 | z-index: 5; 37 | } -------------------------------------------------------------------------------- /giscube_app/static/css/style.css: -------------------------------------------------------------------------------- 1 | body{width: 99%; padding-top: 3px; padding-bottom: 3px;} 2 | #logo{box-shadow: 3px 0px 4px #939393; width: 100%;} 3 | #map-container{max-width: none; height: 100%;} 4 | #map{box-shadow: 0px 0px 5px 4px #939393; width: 100%; height: 90%; margin-top: 10px;} 5 | #side_menu{background: #2f2f2f; height: 100%; box-shadow: 3px 0px 4px #939393; position: fixed; margin-top: 5.5%;} 6 | #github{width: 2%; position:fixed; bottom:0;} 7 | #uploaded_files{border-left: 1px groove #c4c2c5; height: 100%;} 8 | .red{color: #ff0600; opacity: 1;} 9 | .right{float: right} 10 | .tree { 11 | min-height:20px; 12 | padding:19px; 13 | margin-bottom:20px; 14 | -webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05); 15 | -moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05); 16 | box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05) 17 | } 18 | .tree li { 19 | list-style-type:none; 20 | margin:0; 21 | padding:10px 5px 0 5px; 22 | position:relative 23 | } 24 | .tree li::before, .tree li::after { 25 | content:''; 26 | left:-20px; 27 | position:absolute; 28 | right:auto 29 | } 30 | .tree li::before { 31 | border-left:1px solid #999; 32 | bottom:50px; 33 | height:100%; 34 | top:0; 35 | width:1px 36 | } 37 | .tree li::after { 38 | border-top:1px solid #999; 39 | height:20px; 40 | top:25px; 41 | width:25px 42 | } 43 | .tree li span { 44 | cursor:pointer; 45 | -moz-border-radius:0px; 46 | -webkit-border-radius:0px; 47 | border:1px solid #999; 48 | border-radius:0px; 49 | display:inline-block; 50 | padding:3px 8px; 51 | text-decoration:none 52 | } 53 | .tree li.parent_li>span { 54 | cursor:pointer 55 | } 56 | .tree>ul>li::before, .tree>ul>li::after { 57 | border:0 58 | } 59 | .tree li:last-child::before { 60 | height:30px 61 | } 62 | .tree li.parent_li>span:hover, .tree li.parent_li>span:hover+ul li span { 63 | background:#eee; 64 | border:1px solid #94a0b4; 65 | color:#000 66 | } 67 | #tools_title{font-size: 30px; color: #31a467; font-weight: 100;} 68 | #tools_subtitle{font-size: 20px; color: #b6af32; font-weight: 100;} 69 | #tool_title{font-size: 15px; color: #4f4d50; font-weight: 200;} -------------------------------------------------------------------------------- /giscube_app/static/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/db.sqlite3 -------------------------------------------------------------------------------- /giscube_app/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /giscube_app/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /giscube_app/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /giscube_app/static/img/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/img/.DS_Store -------------------------------------------------------------------------------- /giscube_app/static/img/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/img/github.png -------------------------------------------------------------------------------- /giscube_app/static/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /giscube_app/static/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /giscube_app/static/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/img/logo.png -------------------------------------------------------------------------------- /giscube_app/static/img/logo_beta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/img/logo_beta.png -------------------------------------------------------------------------------- /giscube_app/static/js/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/js/.DS_Store -------------------------------------------------------------------------------- /giscube_app/static/js/KML.js: -------------------------------------------------------------------------------- 1 | /*global L: true */ 2 | 3 | L.KML = L.FeatureGroup.extend({ 4 | options: { 5 | async: true 6 | }, 7 | 8 | initialize: function(kml, options) { 9 | L.Util.setOptions(this, options); 10 | this._kml = kml; 11 | this._layers = {}; 12 | 13 | if (kml) { 14 | this.addKML(kml, options, this.options.async); 15 | } 16 | }, 17 | 18 | loadXML: function(url, cb, options, async) { 19 | if (async == undefined) async = this.options.async; 20 | if (options == undefined) options = this.options; 21 | 22 | var req = new window.XMLHttpRequest(); 23 | req.open('GET', url, async); 24 | try { 25 | req.overrideMimeType('text/xml'); // unsupported by IE 26 | } catch(e) {} 27 | req.onreadystatechange = function() { 28 | if (req.readyState != 4) return; 29 | if(req.status == 200) cb(req.responseXML, options); 30 | }; 31 | req.send(null); 32 | }, 33 | 34 | addKML: function(url, options, async) { 35 | var _this = this; 36 | var cb = function(gpx, options) { _this._addKML(gpx, options) }; 37 | this.loadXML(url, cb, options, async); 38 | }, 39 | 40 | _addKML: function(xml, options) { 41 | var layers = L.KML.parseKML(xml); 42 | if (!layers || !layers.length) return; 43 | for (var i = 0; i < layers.length; i++) 44 | { 45 | this.fire('addlayer', { 46 | layer: layers[i] 47 | }); 48 | this.addLayer(layers[i]); 49 | } 50 | this.latLngs = L.KML.getLatLngs(xml); 51 | this.fire("loaded"); 52 | }, 53 | 54 | latLngs: [] 55 | }); 56 | 57 | L.Util.extend(L.KML, { 58 | 59 | parseKML: function (xml) { 60 | var style = this.parseStyle(xml); 61 | this.parseStyleMap(xml, style); 62 | var el = xml.getElementsByTagName("Folder"); 63 | var layers = [], l; 64 | for (var i = 0; i < el.length; i++) { 65 | if (!this._check_folder(el[i])) { continue; } 66 | l = this.parseFolder(el[i], style); 67 | if (l) { layers.push(l); } 68 | } 69 | el = xml.getElementsByTagName('Placemark'); 70 | for (var j = 0; j < el.length; j++) { 71 | if (!this._check_folder(el[j])) { continue; } 72 | l = this.parsePlacemark(el[j], xml, style); 73 | if (l) { layers.push(l); } 74 | } 75 | return layers; 76 | }, 77 | 78 | // Return false if e's first parent Folder is not [folder] 79 | // - returns true if no parent Folders 80 | _check_folder: function (e, folder) { 81 | e = e.parentElement; 82 | while (e && e.tagName !== "Folder") 83 | { 84 | e = e.parentElement; 85 | } 86 | return !e || e === folder; 87 | }, 88 | 89 | parseStyle: function (xml) { 90 | var style = {}; 91 | var sl = xml.getElementsByTagName("Style"); 92 | 93 | //for (var i = 0; i < sl.length; i++) { 94 | var attributes = {color: true, width: true, Icon: true, href: true, 95 | hotSpot: true}; 96 | 97 | function _parse(xml) { 98 | var options = {}; 99 | for (var i = 0; i < xml.childNodes.length; i++) { 100 | var e = xml.childNodes[i]; 101 | var key = e.tagName; 102 | if (!attributes[key]) { continue; } 103 | if (key === 'hotSpot') 104 | { 105 | for (var j = 0; j < e.attributes.length; j++) { 106 | options[e.attributes[j].name] = e.attributes[j].nodeValue; 107 | } 108 | } else { 109 | var value = e.childNodes[0].nodeValue; 110 | if (key === 'color') { 111 | options.opacity = parseInt(value.substring(0, 2), 16) / 255.0; 112 | options.color = "#" + value.substring(6, 8) + value.substring(4, 6) + value.substring(2, 4); 113 | } else if (key === 'width') { 114 | options.weight = value; 115 | } else if (key === 'Icon') { 116 | ioptions = _parse(e); 117 | if (ioptions.href) { options.href = ioptions.href; } 118 | } else if (key === 'href') { 119 | options.href = value; 120 | } 121 | } 122 | } 123 | return options; 124 | } 125 | 126 | for (var i = 0; i < sl.length; i++) { 127 | var e = sl[i], el; 128 | var options = {}, poptions = {}, ioptions = {}; 129 | el = e.getElementsByTagName("LineStyle"); 130 | if (el && el[0]) { options = _parse(el[0]); } 131 | el = e.getElementsByTagName("PolyStyle"); 132 | if (el && el[0]) { poptions = _parse(el[0]); } 133 | if (poptions.color) { options.fillColor = poptions.color; } 134 | if (poptions.opacity) { options.fillOpacity = poptions.opacity; } 135 | el = e.getElementsByTagName("IconStyle"); 136 | if (el && el[0]) { ioptions = _parse(el[0]); } 137 | if (ioptions.href) { 138 | // save anchor info until the image is loaded 139 | options.icon = new L.KMLIcon({ 140 | iconUrl: ioptions.href, 141 | shadowUrl: null, 142 | iconAnchorRef: {x: ioptions.x, y: ioptions.y}, 143 | iconAnchorType: {x: ioptions.xunits, y: ioptions.yunits} 144 | }); 145 | } 146 | style['#' + e.getAttribute('id')] = options; 147 | } 148 | return style; 149 | }, 150 | 151 | parseStyleMap: function (xml, existingStyles) { 152 | var sl = xml.getElementsByTagName("StyleMap"); 153 | 154 | for (var i = 0; i < sl.length; i++) { 155 | var e = sl[i], el; 156 | var smKey, smStyleUrl; 157 | 158 | el = e.getElementsByTagName("key"); 159 | if (el && el[0]) { smKey = el[0].textContent; } 160 | el = e.getElementsByTagName("styleUrl"); 161 | if (el && el[0]) { smStyleUrl = el[0].textContent; } 162 | 163 | if (smKey=='normal') 164 | { 165 | existingStyles['#' + e.getAttribute('id')] = existingStyles[smStyleUrl]; 166 | } 167 | } 168 | 169 | return; 170 | }, 171 | 172 | parseFolder: function (xml, style) { 173 | var el, layers = [], l; 174 | el = xml.getElementsByTagName('Folder'); 175 | for (var i = 0; i < el.length; i++) { 176 | if (!this._check_folder(el[i], xml)) { continue; } 177 | l = this.parseFolder(el[i], style); 178 | if (l) { layers.push(l); } 179 | } 180 | el = xml.getElementsByTagName('Placemark'); 181 | for (var j = 0; j < el.length; j++) { 182 | if (!this._check_folder(el[j], xml)) { continue; } 183 | l = this.parsePlacemark(el[j], xml, style); 184 | if (l) { layers.push(l); } 185 | } 186 | if (!layers.length) { return; } 187 | if (layers.length === 1) { return layers[0]; } 188 | return new L.FeatureGroup(layers); 189 | }, 190 | 191 | parsePlacemark: function (place, xml, style) { 192 | var i, j, el, options = {}; 193 | el = place.getElementsByTagName('styleUrl'); 194 | for (i = 0; i < el.length; i++) { 195 | var url = el[i].childNodes[0].nodeValue; 196 | for (var a in style[url]) 197 | { 198 | // for jshint 199 | if (true) 200 | { 201 | options[a] = style[url][a]; 202 | } 203 | } 204 | } 205 | var layers = []; 206 | 207 | var parse = ['LineString', 'Polygon', 'Point']; 208 | for (j in parse) { 209 | // for jshint 210 | if (true) 211 | { 212 | var tag = parse[j]; 213 | el = place.getElementsByTagName(tag); 214 | for (i = 0; i < el.length; i++) { 215 | var l = this["parse" + tag](el[i], xml, options); 216 | if (l) { layers.push(l); } 217 | } 218 | } 219 | } 220 | 221 | if (!layers.length) { 222 | return; 223 | } 224 | var layer = layers[0]; 225 | if (layers.length > 1) { 226 | layer = new L.FeatureGroup(layers); 227 | } 228 | 229 | var name, descr = ""; 230 | el = place.getElementsByTagName('name'); 231 | if (el.length && el[0].childNodes.length) { 232 | name = el[0].childNodes[0].nodeValue; 233 | } 234 | el = place.getElementsByTagName('description'); 235 | for (i = 0; i < el.length; i++) { 236 | for (j = 0; j < el[i].childNodes.length; j++) { 237 | descr = descr + el[i].childNodes[j].nodeValue; 238 | } 239 | } 240 | 241 | if (name) { 242 | layer.bindPopup("

" + name + "

" + descr); 243 | } 244 | 245 | return layer; 246 | }, 247 | 248 | parseCoords: function (xml) { 249 | var el = xml.getElementsByTagName('coordinates'); 250 | return this._read_coords(el[0]); 251 | }, 252 | 253 | parseLineString: function (line, xml, options) { 254 | var coords = this.parseCoords(line); 255 | if (!coords.length) { return; } 256 | return new L.Polyline(coords, options); 257 | }, 258 | 259 | parsePoint: function (line, xml, options) { 260 | var el = line.getElementsByTagName('coordinates'); 261 | if (!el.length) { 262 | return; 263 | } 264 | var ll = el[0].childNodes[0].nodeValue.split(','); 265 | return new L.KMLMarker(new L.LatLng(ll[1], ll[0]), options); 266 | }, 267 | 268 | parsePolygon: function (line, xml, options) { 269 | var el, polys = [], inner = [], i, coords; 270 | el = line.getElementsByTagName('outerBoundaryIs'); 271 | for (i = 0; i < el.length; i++) { 272 | coords = this.parseCoords(el[i]); 273 | if (coords) { 274 | polys.push(coords); 275 | } 276 | } 277 | el = line.getElementsByTagName('innerBoundaryIs'); 278 | for (i = 0; i < el.length; i++) { 279 | coords = this.parseCoords(el[i]); 280 | if (coords) { 281 | inner.push(coords); 282 | } 283 | } 284 | if (!polys.length) { 285 | return; 286 | } 287 | if (options.fillColor) { 288 | options.fill = true; 289 | } 290 | if (polys.length === 1) { 291 | return new L.Polygon(polys.concat(inner), options); 292 | } 293 | return new L.MultiPolygon(polys, options); 294 | }, 295 | 296 | getLatLngs: function (xml) { 297 | var el = xml.getElementsByTagName('coordinates'); 298 | var coords = []; 299 | for (var j = 0; j < el.length; j++) { 300 | // text might span many childnodes 301 | coords = coords.concat(this._read_coords(el[j])); 302 | } 303 | return coords; 304 | }, 305 | 306 | _read_coords: function (el) { 307 | var text = "", coords = [], i; 308 | for (i = 0; i < el.childNodes.length; i++) { 309 | text = text + el.childNodes[i].nodeValue; 310 | } 311 | text = text.split(/[\s\n]+/); 312 | for (i = 0; i < text.length; i++) { 313 | var ll = text[i].split(','); 314 | if (ll.length < 2) { 315 | continue; 316 | } 317 | coords.push(new L.LatLng(ll[1], ll[0])); 318 | } 319 | return coords; 320 | } 321 | 322 | }); 323 | 324 | L.KMLIcon = L.Icon.extend({ 325 | 326 | createIcon: function () { 327 | var img = this._createIcon('icon'); 328 | img.onload = function () { 329 | var i = new Image(); 330 | i.src = this.src; 331 | this.style.width = i.width + 'px'; 332 | this.style.height = i.height + 'px'; 333 | 334 | if (this.anchorType.x === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') { 335 | img.style.marginLeft = (-this.anchor.x * i.width) + 'px'; 336 | } 337 | if (this.anchorType.y === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') { 338 | img.style.marginTop = (-(1 - this.anchor.y) * i.height) + 'px'; 339 | } 340 | this.style.display = ""; 341 | }; 342 | return img; 343 | }, 344 | 345 | _setIconStyles: function (img, name) { 346 | L.Icon.prototype._setIconStyles.apply(this, [img, name]) 347 | // save anchor information to the image 348 | img.anchor = this.options.iconAnchorRef; 349 | img.anchorType = this.options.iconAnchorType; 350 | } 351 | }); 352 | 353 | 354 | L.KMLMarker = L.Marker.extend({ 355 | options: { 356 | icon: new L.KMLIcon.Default() 357 | } 358 | }); 359 | -------------------------------------------------------------------------------- /giscube_app/static/js/collapse.js: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Bootstrap: collapse.js v3.0.0 3 | * http://twbs.github.com/bootstrap/javascript.html#collapse 4 | * ======================================================================== 5 | * Copyright 2012 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ======================================================================== */ 19 | 20 | 21 | +function ($) { "use strict"; 22 | 23 | // COLLAPSE PUBLIC CLASS DEFINITION 24 | // ================================ 25 | 26 | var Collapse = function (element, options) { 27 | this.$element = $(element) 28 | this.options = $.extend({}, Collapse.DEFAULTS, options) 29 | this.transitioning = null 30 | 31 | if (this.options.parent) this.$parent = $(this.options.parent) 32 | if (this.options.toggle) this.toggle() 33 | } 34 | 35 | Collapse.DEFAULTS = { 36 | toggle: true 37 | } 38 | 39 | Collapse.prototype.dimension = function () { 40 | var hasWidth = this.$element.hasClass('width') 41 | return hasWidth ? 'width' : 'height' 42 | } 43 | 44 | Collapse.prototype.show = function () { 45 | if (this.transitioning || this.$element.hasClass('in')) return 46 | 47 | var startEvent = $.Event('show.bs.collapse') 48 | this.$element.trigger(startEvent) 49 | if (startEvent.isDefaultPrevented()) return 50 | 51 | var actives = this.$parent && this.$parent.find('> .panel > .in') 52 | 53 | if (actives && actives.length) { 54 | var hasData = actives.data('bs.collapse') 55 | if (hasData && hasData.transitioning) return 56 | actives.collapse('hide') 57 | hasData || actives.data('bs.collapse', null) 58 | } 59 | 60 | var dimension = this.dimension() 61 | 62 | this.$element 63 | .removeClass('collapse') 64 | .addClass('collapsing') 65 | [dimension](0) 66 | 67 | this.transitioning = 1 68 | 69 | var complete = function () { 70 | this.$element 71 | .removeClass('collapsing') 72 | .addClass('in') 73 | [dimension]('auto') 74 | this.transitioning = 0 75 | this.$element.trigger('shown.bs.collapse') 76 | } 77 | 78 | if (!$.support.transition) return complete.call(this) 79 | 80 | var scrollSize = $.camelCase(['scroll', dimension].join('-')) 81 | 82 | this.$element 83 | .one($.support.transition.end, $.proxy(complete, this)) 84 | .emulateTransitionEnd(350) 85 | [dimension](this.$element[0][scrollSize]) 86 | } 87 | 88 | Collapse.prototype.hide = function () { 89 | if (this.transitioning || !this.$element.hasClass('in')) return 90 | 91 | var startEvent = $.Event('hide.bs.collapse') 92 | this.$element.trigger(startEvent) 93 | if (startEvent.isDefaultPrevented()) return 94 | 95 | var dimension = this.dimension() 96 | 97 | this.$element 98 | [dimension](this.$element[dimension]()) 99 | [0].offsetHeight 100 | 101 | this.$element 102 | .addClass('collapsing') 103 | .removeClass('collapse') 104 | .removeClass('in') 105 | 106 | this.transitioning = 1 107 | 108 | var complete = function () { 109 | this.transitioning = 0 110 | this.$element 111 | .trigger('hidden.bs.collapse') 112 | .removeClass('collapsing') 113 | .addClass('collapse') 114 | } 115 | 116 | if (!$.support.transition) return complete.call(this) 117 | 118 | this.$element 119 | [dimension](0) 120 | .one($.support.transition.end, $.proxy(complete, this)) 121 | .emulateTransitionEnd(350) 122 | } 123 | 124 | Collapse.prototype.toggle = function () { 125 | this[this.$element.hasClass('in') ? 'hide' : 'show']() 126 | } 127 | 128 | 129 | // COLLAPSE PLUGIN DEFINITION 130 | // ========================== 131 | 132 | var old = $.fn.collapse 133 | 134 | $.fn.collapse = function (option) { 135 | return this.each(function () { 136 | var $this = $(this) 137 | var data = $this.data('bs.collapse') 138 | var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) 139 | 140 | if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) 141 | if (typeof option == 'string') data[option]() 142 | }) 143 | } 144 | 145 | $.fn.collapse.Constructor = Collapse 146 | 147 | 148 | // COLLAPSE NO CONFLICT 149 | // ==================== 150 | 151 | $.fn.collapse.noConflict = function () { 152 | $.fn.collapse = old 153 | return this 154 | } 155 | 156 | 157 | // COLLAPSE DATA-API 158 | // ================= 159 | 160 | $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { 161 | var $this = $(this), href 162 | var target = $this.attr('data-target') 163 | || e.preventDefault() 164 | || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 165 | var $target = $(target) 166 | var data = $target.data('bs.collapse') 167 | var option = data ? 'toggle' : $this.data() 168 | var parent = $this.attr('data-parent') 169 | var $parent = parent && $(parent) 170 | 171 | if (!data || !data.transitioning) { 172 | if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') 173 | $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') 174 | } 175 | 176 | $target.collapse(option) 177 | }) 178 | 179 | }(window.jQuery); 180 | -------------------------------------------------------------------------------- /giscube_app/static/js/jquery.fileupload-process.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery File Upload Processing Plugin 1.2.2 3 | * https://github.com/blueimp/jQuery-File-Upload 4 | * 5 | * Copyright 2012, Sebastian Tschan 6 | * https://blueimp.net 7 | * 8 | * Licensed under the MIT license: 9 | * http://www.opensource.org/licenses/MIT 10 | */ 11 | 12 | /*jslint nomen: true, unparam: true */ 13 | /*global define, window */ 14 | 15 | (function (factory) { 16 | 'use strict'; 17 | if (typeof define === 'function' && define.amd) { 18 | // Register as an anonymous AMD module: 19 | define([ 20 | 'jquery', 21 | './jquery.fileupload' 22 | ], factory); 23 | } else { 24 | // Browser globals: 25 | factory( 26 | window.jQuery 27 | ); 28 | } 29 | }(function ($) { 30 | 'use strict'; 31 | 32 | var originalAdd = $.blueimp.fileupload.prototype.options.add; 33 | 34 | // The File Upload Processing plugin extends the fileupload widget 35 | // with file processing functionality: 36 | $.widget('blueimp.fileupload', $.blueimp.fileupload, { 37 | 38 | options: { 39 | // The list of processing actions: 40 | processQueue: [ 41 | /* 42 | { 43 | action: 'log', 44 | type: 'debug' 45 | } 46 | */ 47 | ], 48 | add: function (e, data) { 49 | var $this = $(this); 50 | data.process(function () { 51 | return $this.fileupload('process', data); 52 | }); 53 | originalAdd.call(this, e, data); 54 | } 55 | }, 56 | 57 | processActions: { 58 | /* 59 | log: function (data, options) { 60 | console[options.type]( 61 | 'Processing "' + data.files[data.index].name + '"' 62 | ); 63 | } 64 | */ 65 | }, 66 | 67 | _processFile: function (data) { 68 | var that = this, 69 | dfd = $.Deferred().resolveWith(that, [data]), 70 | chain = dfd.promise(); 71 | this._trigger('process', null, data); 72 | $.each(data.processQueue, function (i, settings) { 73 | var func = function (data) { 74 | return that.processActions[settings.action].call( 75 | that, 76 | data, 77 | settings 78 | ); 79 | }; 80 | chain = chain.pipe(func, settings.always && func); 81 | }); 82 | chain 83 | .done(function () { 84 | that._trigger('processdone', null, data); 85 | that._trigger('processalways', null, data); 86 | }) 87 | .fail(function () { 88 | that._trigger('processfail', null, data); 89 | that._trigger('processalways', null, data); 90 | }); 91 | return chain; 92 | }, 93 | 94 | // Replaces the settings of each processQueue item that 95 | // are strings starting with an "@", using the remaining 96 | // substring as key for the option map, 97 | // e.g. "@autoUpload" is replaced with options.autoUpload: 98 | _transformProcessQueue: function (options) { 99 | var processQueue = []; 100 | $.each(options.processQueue, function () { 101 | var settings = {}, 102 | action = this.action, 103 | prefix = this.prefix === true ? action : this.prefix; 104 | $.each(this, function (key, value) { 105 | if ($.type(value) === 'string' && 106 | value.charAt(0) === '@') { 107 | settings[key] = options[ 108 | value.slice(1) || (prefix ? prefix + 109 | key.charAt(0).toUpperCase() + key.slice(1) : key) 110 | ]; 111 | } else { 112 | settings[key] = value; 113 | } 114 | 115 | }); 116 | processQueue.push(settings); 117 | }); 118 | options.processQueue = processQueue; 119 | }, 120 | 121 | // Returns the number of files currently in the processsing queue: 122 | processing: function () { 123 | return this._processing; 124 | }, 125 | 126 | // Processes the files given as files property of the data parameter, 127 | // returns a Promise object that allows to bind callbacks: 128 | process: function (data) { 129 | var that = this, 130 | options = $.extend({}, this.options, data); 131 | if (options.processQueue && options.processQueue.length) { 132 | this._transformProcessQueue(options); 133 | if (this._processing === 0) { 134 | this._trigger('processstart'); 135 | } 136 | $.each(data.files, function (index) { 137 | var opts = index ? $.extend({}, options) : options, 138 | func = function () { 139 | return that._processFile(opts); 140 | }; 141 | opts.index = index; 142 | that._processing += 1; 143 | that._processingQueue = that._processingQueue.pipe(func, func) 144 | .always(function () { 145 | that._processing -= 1; 146 | if (that._processing === 0) { 147 | that._trigger('processstop'); 148 | } 149 | }); 150 | }); 151 | } 152 | return this._processingQueue; 153 | }, 154 | 155 | _create: function () { 156 | this._super(); 157 | this._processing = 0; 158 | this._processingQueue = $.Deferred().resolveWith(this) 159 | .promise(); 160 | } 161 | 162 | }); 163 | 164 | })); 165 | -------------------------------------------------------------------------------- /giscube_app/static/js/jquery.xdr-transport.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery XDomainRequest Transport Plugin 1.1.3 3 | * https://github.com/blueimp/jQuery-File-Upload 4 | * 5 | * Copyright 2011, Sebastian Tschan 6 | * https://blueimp.net 7 | * 8 | * Licensed under the MIT license: 9 | * http://www.opensource.org/licenses/MIT 10 | * 11 | * Based on Julian Aubourg's ajaxHooks xdr.js: 12 | * https://github.com/jaubourg/ajaxHooks/ 13 | */ 14 | 15 | /*jslint unparam: true */ 16 | /*global define, window, XDomainRequest */ 17 | 18 | (function (factory) { 19 | 'use strict'; 20 | if (typeof define === 'function' && define.amd) { 21 | // Register as an anonymous AMD module: 22 | define(['jquery'], factory); 23 | } else { 24 | // Browser globals: 25 | factory(window.jQuery); 26 | } 27 | }(function ($) { 28 | 'use strict'; 29 | if (window.XDomainRequest && !$.support.cors) { 30 | $.ajaxTransport(function (s) { 31 | if (s.crossDomain && s.async) { 32 | if (s.timeout) { 33 | s.xdrTimeout = s.timeout; 34 | delete s.timeout; 35 | } 36 | var xdr; 37 | return { 38 | send: function (headers, completeCallback) { 39 | var addParamChar = /\?/.test(s.url) ? '&' : '?'; 40 | function callback(status, statusText, responses, responseHeaders) { 41 | xdr.onload = xdr.onerror = xdr.ontimeout = $.noop; 42 | xdr = null; 43 | completeCallback(status, statusText, responses, responseHeaders); 44 | } 45 | xdr = new XDomainRequest(); 46 | // XDomainRequest only supports GET and POST: 47 | if (s.type === 'DELETE') { 48 | s.url = s.url + addParamChar + '_method=DELETE'; 49 | s.type = 'POST'; 50 | } else if (s.type === 'PUT') { 51 | s.url = s.url + addParamChar + '_method=PUT'; 52 | s.type = 'POST'; 53 | } else if (s.type === 'PATCH') { 54 | s.url = s.url + addParamChar + '_method=PATCH'; 55 | s.type = 'POST'; 56 | } 57 | xdr.open(s.type, s.url); 58 | xdr.onload = function () { 59 | callback( 60 | 200, 61 | 'OK', 62 | {text: xdr.responseText}, 63 | 'Content-Type: ' + xdr.contentType 64 | ); 65 | }; 66 | xdr.onerror = function () { 67 | callback(404, 'Not Found'); 68 | }; 69 | if (s.xdrTimeout) { 70 | xdr.ontimeout = function () { 71 | callback(0, 'timeout'); 72 | }; 73 | xdr.timeout = s.xdrTimeout; 74 | } 75 | xdr.send((s.hasContent && s.data) || null); 76 | }, 77 | abort: function () { 78 | if (xdr) { 79 | xdr.onerror = $.noop(); 80 | xdr.abort(); 81 | } 82 | } 83 | }; 84 | } 85 | }); 86 | } 87 | })); 88 | -------------------------------------------------------------------------------- /giscube_app/static/js/kml-layer.js: -------------------------------------------------------------------------------- 1 | var map = new OpenLayers.Map({ 2 | div: "map", 3 | layers: [ 4 | new OpenLayers.Layer.WMS( 5 | "WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", 6 | {layers: "basic"} 7 | ), 8 | new OpenLayers.Layer.Vector("KML", { 9 | strategies: [new OpenLayers.Strategy.Fixed()], 10 | protocol: new OpenLayers.Protocol.HTTP({ 11 | url: "test.kml", 12 | format: new OpenLayers.Format.KML({ 13 | extractStyles: true, 14 | extractAttributes: true, 15 | maxDepth: 2 16 | }) 17 | }) 18 | }) 19 | ], 20 | center: new OpenLayers.LonLat(-112.169, 36.099), 21 | zoom: 11 22 | }); -------------------------------------------------------------------------------- /giscube_app/static/js/leaflet.filelayer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Load files *locally* (GeoJSON, KML, GPX) into the map 3 | * using the HTML5 File API. 4 | * 5 | * Requires Pavel Shramov's GPX.js 6 | * https://github.com/shramov/leaflet-plugins/blob/d74d67/layer/vector/GPX.js 7 | */ 8 | var FileLoader = L.Class.extend({ 9 | includes: L.Mixin.Events, 10 | options: { 11 | layerOptions: {} 12 | }, 13 | 14 | initialize: function (map, options) { 15 | this._map = map; 16 | L.Util.setOptions(this, options); 17 | 18 | this._parsers = { 19 | 'geojson': this._loadGeoJSON, 20 | 'gpx': this._convertToGeoJSON, 21 | 'kml': this._convertToGeoJSON 22 | }; 23 | }, 24 | 25 | load: function (file /* File */) { 26 | // Check file extension 27 | var ext = file.name.split('.').pop(), 28 | parser = this._parsers[ext]; 29 | if (!parser) { 30 | window.alert("Unsupported file type " + file.type + '(' + ext + ')'); 31 | return; 32 | } 33 | // Read selected file using HTML5 File API 34 | var reader = new FileReader(); 35 | reader.onload = L.Util.bind(function (e) { 36 | this.fire('data:loading', {filename: file.name, format: ext}); 37 | var layer = parser.call(this, e.target.result, ext); 38 | this.fire('data:loaded', {layer: layer, filename: file.name, format: ext}); 39 | }, this); 40 | reader.readAsText(file); 41 | }, 42 | 43 | _loadGeoJSON: function (content) { 44 | if (typeof content == 'string') { 45 | content = JSON.parse(content); 46 | } 47 | return L.geoJson(content, this.options.layerOptions).addTo(this._map); 48 | }, 49 | 50 | _convertToGeoJSON: function (content, format) { 51 | // Format is either 'gpx' or 'kml' 52 | if (typeof content == 'string') { 53 | content = ( new window.DOMParser() ).parseFromString(content, "text/xml"); 54 | } 55 | var geojson = toGeoJSON[format](content); 56 | return this._loadGeoJSON(geojson); 57 | } 58 | }); 59 | 60 | 61 | L.Control.FileLayerLoad = L.Control.extend({ 62 | statics: { 63 | TITLE: 'Load local file (GPX, KML, GeoJSON)', 64 | LABEL: '⌅' 65 | }, 66 | options: { 67 | position: 'topleft', 68 | fitBounds: true, 69 | layerOptions: {} 70 | }, 71 | 72 | initialize: function (options) { 73 | L.Util.setOptions(this, options); 74 | this.loader = null; 75 | }, 76 | 77 | onAdd: function (map) { 78 | this.loader = new FileLoader(map, {layerOptions: this.options.layerOptions}); 79 | 80 | this.loader.on('data:loaded', function (e) { 81 | // Fit bounds after loading 82 | if (this.options.fitBounds) { 83 | window.setTimeout(function () { 84 | map.fitBounds(e.layer.getBounds()).zoomOut(); 85 | }, 500); 86 | } 87 | }, this); 88 | 89 | // Initialize Drag-and-drop 90 | this._initDragAndDrop(map); 91 | 92 | // Initialize map control 93 | return this._initContainer(); 94 | }, 95 | 96 | _initDragAndDrop: function (map) { 97 | var fileLoader = this.loader, 98 | dropbox = map._container; 99 | 100 | var callbacks = { 101 | dragenter: function () { 102 | map.scrollWheelZoom.disable(); 103 | }, 104 | dragleave: function () { 105 | map.scrollWheelZoom.enable(); 106 | }, 107 | dragover: function (e) { 108 | e.stopPropagation(); 109 | e.preventDefault(); 110 | }, 111 | drop: function (e) { 112 | e.stopPropagation(); 113 | e.preventDefault(); 114 | 115 | var files = Array.prototype.slice.apply(e.dataTransfer.files), 116 | i = files.length; 117 | setTimeout(function(){ 118 | fileLoader.load(files.shift()); 119 | if (files.length > 0) { 120 | setTimeout(arguments.callee, 25); 121 | } 122 | }, 25); 123 | map.scrollWheelZoom.enable(); 124 | } 125 | }; 126 | for (var name in callbacks) 127 | dropbox.addEventListener(name, callbacks[name], false); 128 | }, 129 | 130 | _initContainer: function () { 131 | // Create an invisible file input 132 | var fileInput = L.DomUtil.create('input', 'hidden', container); 133 | fileInput.type = 'file'; 134 | fileInput.accept = '.gpx,.kml,.geojson'; 135 | fileInput.style.display = 'none'; 136 | // Load on file change 137 | var fileLoader = this.loader; 138 | fileInput.addEventListener("change", function (e) { 139 | fileLoader.load(this.files[0]); 140 | }, false); 141 | 142 | // Create a button, and bind click on hidden file input 143 | var zoomName = 'leaflet-control-filelayer leaflet-control-zoom', 144 | barName = 'leaflet-bar', 145 | partName = barName + '-part', 146 | container = L.DomUtil.create('div', zoomName + ' ' + barName); 147 | var link = L.DomUtil.create('a', zoomName + '-in ' + partName, container); 148 | link.innerHTML = L.Control.FileLayerLoad.LABEL; 149 | link.href = '#'; 150 | link.title = L.Control.FileLayerLoad.TITLE; 151 | 152 | var stop = L.DomEvent.stopPropagation; 153 | L.DomEvent 154 | .on(link, 'click', stop) 155 | .on(link, 'mousedown', stop) 156 | .on(link, 'dblclick', stop) 157 | .on(link, 'click', L.DomEvent.preventDefault) 158 | .on(link, 'click', function (e) { 159 | fileInput.click(); 160 | e.preventDefault(); 161 | }); 162 | return container; 163 | } 164 | }); 165 | 166 | L.Control.fileLayerLoad = function (options) { 167 | return new L.Control.FileLayerLoad(options); 168 | }; 169 | -------------------------------------------------------------------------------- /giscube_app/static/js/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery File Upload Plugin JS Example 8.8.2 3 | * https://github.com/blueimp/jQuery-File-Upload 4 | * 5 | * Copyright 2010, Sebastian Tschan 6 | * https://blueimp.net 7 | * 8 | * Licensed under the MIT license: 9 | * http://www.opensource.org/licenses/MIT 10 | */ 11 | 12 | /*jslint nomen: true, regexp: true */ 13 | /*global $, window, blueimp */ 14 | 15 | $(function () { 16 | 'use strict'; 17 | 18 | // Initialize the jQuery File Upload widget: 19 | $('#fileupload').fileupload({ 20 | // Uncomment the following to send cross-domain cookies: 21 | //xhrFields: {withCredentials: true}, 22 | url: 'server/php/' 23 | }); 24 | 25 | // Enable iframe cross-domain access via redirect option: 26 | $('#fileupload').fileupload( 27 | 'option', 28 | 'redirect', 29 | window.location.href.replace( 30 | /\/[^\/]*$/, 31 | '/cors/result.html?%s' 32 | ) 33 | ); 34 | 35 | if (window.location.hostname === 'blueimp.github.io') { 36 | // Demo settings: 37 | $('#fileupload').fileupload('option', { 38 | url: '//jquery-file-upload.appspot.com/', 39 | // Enable image resizing, except for Android and Opera, 40 | // which actually support image resizing, but fail to 41 | // send Blob objects via XHR requests: 42 | disableImageResize: /Android(?!.*Chrome)|Opera/ 43 | .test(window.navigator.userAgent), 44 | maxFileSize: 5000000, 45 | acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i 46 | }); 47 | // Upload server status check for browsers with CORS support: 48 | if ($.support.cors) { 49 | $.ajax({ 50 | url: '//jquery-file-upload.appspot.com/', 51 | type: 'HEAD' 52 | }).fail(function () { 53 | $('
') 54 | .text('Upload server currently unavailable - ' + 55 | new Date()) 56 | .appendTo('#fileupload'); 57 | }); 58 | } 59 | } else { 60 | // Load existing files: 61 | $('#fileupload').addClass('fileupload-processing'); 62 | $.ajax({ 63 | // Uncomment the following to send cross-domain cookies: 64 | //xhrFields: {withCredentials: true}, 65 | url: $('#fileupload').fileupload('option', 'url'), 66 | dataType: 'json', 67 | context: $('#fileupload')[0] 68 | }).always(function () { 69 | $(this).removeClass('fileupload-processing'); 70 | }).done(function (result) { 71 | $(this).fileupload('option', 'done') 72 | .call(this, null, {result: result}); 73 | }); 74 | } 75 | 76 | }); 77 | -------------------------------------------------------------------------------- /giscube_app/static/js/togeojson.js: -------------------------------------------------------------------------------- 1 | toGeoJSON = (function() { 2 | 'use strict'; 3 | 4 | var removeSpace = (/\s*/g), 5 | trimSpace = (/^\s*|\s*$/g), 6 | splitSpace = (/\s+/); 7 | // generate a short, numeric hash of a string 8 | function okhash(x) { 9 | if (!x || !x.length) return 0; 10 | for (var i = 0, h = 0; i < x.length; i++) { 11 | h = ((h << 5) - h) + x.charCodeAt(i) | 0; 12 | } return h; 13 | } 14 | // all Y children of X 15 | function get(x, y) { return x.getElementsByTagName(y); } 16 | function attr(x, y) { return x.getAttribute(y); } 17 | function attrf(x, y) { return parseFloat(attr(x, y)); } 18 | // one Y child of X, if any, otherwise null 19 | function get1(x, y) { var n = get(x, y); return n.length ? n[0] : null; } 20 | // cast array x into numbers 21 | function numarray(x) { 22 | for (var j = 0, o = []; j < x.length; j++) o[j] = parseFloat(x[j]); 23 | return o; 24 | } 25 | function clean(x) { 26 | var o = {}; 27 | for (var i in x) if (x[i]) o[i] = x[i]; 28 | return o; 29 | } 30 | // get the content of a text node, if any 31 | function nodeVal(x) { return x && x.firstChild && x.firstChild.nodeValue; } 32 | // get one coordinate from a coordinate array, if any 33 | function coord1(v) { return numarray(v.replace(removeSpace, '').split(',')); } 34 | // get all coordinates from a coordinate array as [[],[]] 35 | function coord(v) { 36 | var coords = v.replace(trimSpace, '').split(splitSpace), 37 | o = []; 38 | for (var i = 0; i < coords.length; i++) { 39 | o.push(coord1(coords[i])); 40 | } 41 | return o; 42 | } 43 | 44 | // create a new feature collection parent object 45 | function fc() { 46 | return { 47 | type: 'FeatureCollection', 48 | features: [] 49 | }; 50 | } 51 | 52 | var t = { 53 | kml: function(doc, o) { 54 | o = o || {}; 55 | 56 | var gj = fc(), 57 | // styleindex keeps track of hashed styles in order to match features 58 | styleIndex = {}, 59 | // atomic geospatial types supported by KML - MultiGeometry is 60 | // handled separately 61 | geotypes = ['Polygon', 'LineString', 'Point'], 62 | // all root placemarks in the file 63 | placemarks = get(doc, 'Placemark'), 64 | styles = get(doc, 'Style'); 65 | 66 | if (o.styles) for (var k = 0; k < styles.length; k++) { 67 | styleIndex['#' + styles[k].id] = okhash(styles[k].innerHTML).toString(16); 68 | } 69 | for (var j = 0; j < placemarks.length; j++) { 70 | gj.features = gj.features.concat(getPlacemark(placemarks[j])); 71 | } 72 | function getGeometry(root) { 73 | var geomNode, geomNodes, i, j, k, geoms = []; 74 | if (get1(root, 'MultiGeometry')) return getGeometry(get1(root, 'MultiGeometry')); 75 | for (i = 0; i < geotypes.length; i++) { 76 | geomNodes = get(root, geotypes[i]); 77 | if (geomNodes) { 78 | for (j = 0; j < geomNodes.length; j++) { 79 | geomNode = geomNodes[j]; 80 | if (geotypes[i] == 'Point') { 81 | geoms.push({ 82 | type: 'Point', 83 | coordinates: coord1(nodeVal(get1(geomNode, 'coordinates'))) 84 | }); 85 | } else if (geotypes[i] == 'LineString') { 86 | geoms.push({ 87 | type: 'LineString', 88 | coordinates: coord(nodeVal(get1(geomNode, 'coordinates'))) 89 | }); 90 | } else if (geotypes[i] == 'Polygon') { 91 | var rings = get(geomNode, 'LinearRing'), 92 | coords = []; 93 | for (k = 0; k < rings.length; k++) { 94 | coords.push(coord(nodeVal(get1(rings[k], 'coordinates')))); 95 | } 96 | geoms.push({ 97 | type: 'Polygon', 98 | coordinates: coords 99 | }); 100 | } 101 | } 102 | } 103 | } 104 | return geoms; 105 | } 106 | function getPlacemark(root) { 107 | var geoms = getGeometry(root), i, properties = {}, 108 | name = nodeVal(get1(root, 'name')), 109 | styleUrl = nodeVal(get1(root, 'styleUrl')), 110 | description = nodeVal(get1(root, 'description')), 111 | extendedData = get1(root, 'ExtendedData'); 112 | 113 | if (!geoms.length) return false; 114 | if (name) properties.name = name; 115 | if (styleUrl && styleIndex[styleUrl]) { 116 | properties.styleUrl = styleUrl; 117 | properties.styleHash = styleIndex[styleUrl]; 118 | } 119 | if (description) properties.description = description; 120 | if (extendedData) { 121 | var datas = get(extendedData, 'Data'), 122 | simpleDatas = get(extendedData, 'SimpleData'); 123 | 124 | for (i = 0; i < datas.length; i++) { 125 | properties[datas[i].getAttribute('name')] = nodeVal(get1(datas[i], 'value')); 126 | } 127 | for (i = 0; i < simpleDatas.length; i++) { 128 | properties[simpleDatas[i].getAttribute('name')] = nodeVal(simpleDatas[i]); 129 | } 130 | } 131 | return [{ 132 | type: 'Feature', 133 | geometry: (geoms.length === 1) ? geoms[0] : { 134 | type: 'GeometryCollection', 135 | geometries: geoms 136 | }, 137 | properties: properties 138 | }]; 139 | } 140 | return gj; 141 | }, 142 | gpx: function(doc, o) { 143 | var i, 144 | tracks = get(doc, 'trk'), 145 | routes = get(doc, 'rte'), 146 | waypoints = get(doc, 'wpt'), 147 | // a feature collection 148 | gj = fc(); 149 | for (i = 0; i < tracks.length; i++) { 150 | gj.features.push(getLinestring(tracks[i], 'trkpt')); 151 | } 152 | for (i = 0; i < routes.length; i++) { 153 | gj.features.push(getLinestring(routes[i], 'rtept')); 154 | } 155 | for (i = 0; i < waypoints.length; i++) { 156 | gj.features.push(getPoint(waypoints[i])); 157 | } 158 | function getLinestring(node, pointname) { 159 | var j, pts = get(node, pointname), line = []; 160 | for (j = 0; j < pts.length; j++) { 161 | line.push([attrf(pts[j], 'lon'), attrf(pts[j], 'lat')]); 162 | } 163 | return { 164 | type: 'Feature', 165 | properties: getProperties(node), 166 | geometry: { 167 | type: 'LineString', 168 | coordinates: line 169 | } 170 | }; 171 | } 172 | function getPoint(node) { 173 | var prop = getProperties(node); 174 | prop['ele'] = nodeVal(get1(node, 'ele')); 175 | prop['sym'] = nodeVal(get1(node, 'sym')); 176 | return { 177 | type: 'Feature', 178 | properties: prop, 179 | geometry: { 180 | type: 'Point', 181 | coordinates: [attrf(node, 'lon'), attrf(node, 'lat')] 182 | } 183 | }; 184 | } 185 | function getProperties(node) { 186 | var meta = ['name', 'desc', 'author', 'copyright', 'link', 187 | 'time', 'keywords'], 188 | prop = {}, 189 | k; 190 | for (k = 0; k < meta.length; k++) { 191 | prop[meta[k]] = nodeVal(get1(node, meta[k])); 192 | } 193 | return clean(prop); 194 | } 195 | return gj; 196 | } 197 | }; 198 | return t; 199 | })(); 200 | 201 | if (typeof module !== 'undefined') module.exports = toGeoJSON; -------------------------------------------------------------------------------- /giscube_app/static/js/transition.js: -------------------------------------------------------------------------------- 1 | /* ======================================================================== 2 | * Bootstrap: transition.js v3.0.0 3 | * http://twbs.github.com/bootstrap/javascript.html#transitions 4 | * ======================================================================== 5 | * Copyright 2013 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ======================================================================== */ 19 | 20 | 21 | +function ($) { "use strict"; 22 | 23 | // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) 24 | // ============================================================ 25 | 26 | function transitionEnd() { 27 | var el = document.createElement('bootstrap') 28 | 29 | var transEndEventNames = { 30 | 'WebkitTransition' : 'webkitTransitionEnd' 31 | , 'MozTransition' : 'transitionend' 32 | , 'OTransition' : 'oTransitionEnd otransitionend' 33 | , 'transition' : 'transitionend' 34 | } 35 | 36 | for (var name in transEndEventNames) { 37 | if (el.style[name] !== undefined) { 38 | return { end: transEndEventNames[name] } 39 | } 40 | } 41 | } 42 | 43 | // http://blog.alexmaccaw.com/css-transitions 44 | $.fn.emulateTransitionEnd = function (duration) { 45 | var called = false, $el = this 46 | $(this).one($.support.transition.end, function () { called = true }) 47 | var callback = function () { if (!called) $($el).trigger($.support.transition.end) } 48 | setTimeout(callback, duration) 49 | return this 50 | } 51 | 52 | $(function () { 53 | $.support.transition = transitionEnd() 54 | }) 55 | 56 | }(window.jQuery); 57 | -------------------------------------------------------------------------------- /giscube_app/static/uploaded_files/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/static/uploaded_files/.DS_Store -------------------------------------------------------------------------------- /giscube_app/templates/data_information/index.html: -------------------------------------------------------------------------------- 1 | {% include 'header.html' %} 2 | {% load staticfiles %} 3 | 4 | 5 |
6 |
7 | 8 |
9 |
10 | 17 |
18 | 19 | 20 | 21 |
22 | 23 | 24 | 30 | 31 | 32 |
33 |
34 | 35 | {% load shp_dict %} 36 |
37 | {% if shp_error %} 38 | 39 | {% else %} 40 | {% for each in shps_info %} 41 |
42 | 49 |
50 |
51 |

File Format:

52 | {{ each|file_format }} 53 |

Number of Layers:

54 | {{ each|num_layer }} 55 |

Layer Name:

56 | {{ each|layer_name }} 57 |

Number of Features:

58 | {{ each|number_of_feature }} 59 |

Layer Type:

60 | {{ each|layer_type }} 61 |

Layer Spatial Reference:

62 | {{ each|layer_spatial_reference }} 63 |

Layer Extend:

64 | {{ each|layer_extend }} 65 |
66 |
67 |
68 | {% endfor %} 69 | {% endif %} 70 |
71 |
72 | 73 | 74 | 75 |
76 | {% load tif_dict %} 77 |
78 | {% if tif_error %} 79 | 80 | {% else %} 81 | {% for each in tifs_info %} 82 |
83 |
84 |

85 | {{ each|file_name }} 86 |

87 |
88 |
89 |
90 |

File Format:

91 | {{ each|file_format }} 92 |

Number of Bands:

93 | {{ each|num_band }} 94 |

X Y size:

95 | {{ each|raster_x_y_size }} 96 |

Raster Projection:

97 | {{ each|raster_projection }} 98 |

Raster Geotransform:

99 | {{ each|raster_geotransform }} 100 |

Raster Origin:

101 | {{ each|raster_origin }} 102 |

Raster Pixle Size:

103 | {{ each|raster_pixle_size }} 104 |
105 |
106 |
107 | {% endfor %} 108 | {% endif %} 109 |
110 |
111 | 112 | 113 |
114 | {% load nc_dict %} 115 |
116 | {% if nc_error %} 117 | 118 | {% else %} 119 | {% for netcdf in ncs_metadata %} 120 |
121 |
122 |

123 | {{ netcdf|file_name }} 124 |

125 |
126 |
127 |
128 | {{ netcdf.nc_metadata }} 129 |
130 |
131 |
132 | {% endfor %} 133 | {% endif %} 134 | 135 | {% if hdf_error %} 136 | 137 | {% else %} 138 | {% for hdf in hdfs_metadata %} 139 |
140 |
141 |

142 | {{ hdf|file_name }} 143 |

144 |
145 |
146 |
147 | {{ hdf.hdf_metadata }} 148 |
149 |
150 |
151 | {% endfor %} 152 | {% endif %} 153 |
154 |
155 |
156 |

Enter OPenDAP URL:

157 |
158 | 159 |
160 | 161 | 162 |
163 |
164 |
165 | 166 |
167 | 168 | 169 | 170 | 171 | 216 | 217 | {% include 'footer.html' %} -------------------------------------------------------------------------------- /giscube_app/templates/data_resource/index.html: -------------------------------------------------------------------------------- 1 | {% include 'header.html' %} 2 | {% load staticfiles %} 3 | 4 | 5 | 6 |
7 |
8 | 9 |
10 |
11 | 18 |
19 | 20 | 21 |
22 | 26 |
27 |
28 |

Supported formats: Shapefile, GeoTIFF, GeoJSON, netCDF and HDF files.

29 |
30 | {% csrf_token %} 31 |

{{ form.non_field_errors }}

32 |

33 | {{ form.docfile.errors }} 34 | {{ form.docfile }} 35 |

36 |

37 | {% if notification %} 38 | 41 | {% endif %} 42 |
43 |
44 |
45 |

1: Enter OPeNDAP URL:

46 |
47 | 48 | 49 |

2: Enter output name

50 |
51 | 52 |
53 | 54 |
55 | 56 | 57 | 58 | 59 |
60 |
61 |
62 |
63 |
64 |
65 | 66 |
67 |

Uploaded Files:

68 | {% if UPLODED_FILES %} 69 |
    70 | {% for file in UPLODED_FILES %} 71 |
  • 72 |   73 | {{ file }} 74 |

  • 75 | {% endfor %} 76 |
77 | {% else %} 78 |

No documents.

79 | {% endif %} 80 |
81 | 82 | 94 | 95 | {% include 'footer.html' %} 96 | -------------------------------------------------------------------------------- /giscube_app/templates/data_visualiser/index.html: -------------------------------------------------------------------------------- 1 | {% include 'header.html' %} 2 | {% load staticfiles %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 |
16 | 23 |
24 | 25 | 26 | 27 |
28 | 33 | 34 |
35 |
36 | {% for json in jsons %} 37 |
38 | 42 |
43 | {% endfor %} 44 |
45 |
46 | {% for geotif in geotifs %} 47 |
48 | 52 |
53 | {% endfor %} 54 |
55 |
56 |

1- Go to "GeoSpatial tools" page

57 |

2- Convert netCDF to GeoTIFF

58 |

3- Come back to "Data Visualiser page"

59 |

4- Visualize the GeoTIIF"

60 |
61 |
62 |
63 | 64 | 65 | 66 |
67 |
68 | Export map (current view) 69 |
70 |
71 |
72 |
73 | 74 | 75 | 233 | 234 | {% include 'footer.html' %} 235 | -------------------------------------------------------------------------------- /giscube_app/templates/footer.html: -------------------------------------------------------------------------------- 1 | {% load dajaxice_templatetags %} 2 | {% load staticfiles %} 3 | 4 | 5 | 6 | 7 | {% dajaxice_js_import %} 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /giscube_app/templates/header.html: -------------------------------------------------------------------------------- 1 | {% load staticfiles %} 2 | 3 | 4 | 5 | 6 | 7 | GISCube 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/buffer_shp.html: -------------------------------------------------------------------------------- 1 | {% load shp_dict %} 2 | 3 | 34 | 35 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/clip_geotiff_by_shp.html: -------------------------------------------------------------------------------- 1 | {% load tif_dict %} 2 | 3 | 4 | 38 | 39 | 51 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/color_table_geotiff.html: -------------------------------------------------------------------------------- 1 | {% load tif_dict %} 2 | 3 | 4 | 40 | 41 | 56 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/coord_to_point_shp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 53 | 54 | 55 | 78 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/extract_shp_table.html: -------------------------------------------------------------------------------- 1 | {% load shp_dict %} 2 | 3 | 4 | 30 | 31 | 32 | 43 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/geotiff_resolution.html: -------------------------------------------------------------------------------- 1 | {% load tif_dict %} 2 | 3 | 4 | 40 | 41 | 54 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/geotiff_to_kml.html: -------------------------------------------------------------------------------- 1 | {% load tif_dict %} 2 | 3 | 4 | 28 | 29 | 40 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/index.html: -------------------------------------------------------------------------------- 1 | {% load staticfiles %} 2 | 3 | 4 | {% include '/tools/re_project_shapefile.html' %} 5 | {% include '/tools/extract_shp_table.html' %} 6 | {% include '/tools/shp_to_kml.html' %} 7 | {% include '/tools/shp_to_tif.html' %} 8 | {% include '/tools/shp_to_json.html' %} 9 | {% include '/tools/coord_to_point_shp.html' %} 10 | {% include '/tools/buffer_shp.html' %} 11 | {% include '/tools/point_inside_shapefile.html' %} 12 | 13 | 14 | 15 | {% include '/tools/re_project_geotiff.html' %} 16 | {% include '/tools/clip_geotiff_by_shp.html' %} 17 | {% include '/tools/geotiff_to_kml.html' %} 18 | {% include '/tools/geotiff_resolution.html' %} 19 | {% include '/tools/tif_to_point_shp.html' %} 20 | {% include '/tools/tif_to_point_json.html' %} 21 | {% include '/tools/color_table_geotiff.html' %} 22 | 23 | 24 | {% include '/tools/netcdf_to_geotiff.html' %} 25 | {% include '/tools/netcdf_to_geojson.html' %} 26 | {% include '/tools/ncdump_header.html' %} 27 | {% include '/tools/ncdump_whole_netcdf.html' %} 28 | 29 | {% include 'header.html' %} 30 | 31 | 32 |
33 |
34 | 35 |
36 |
37 | 44 |
45 | 46 |
47 | 48 |
49 |
50 |
    51 |
  • 52 |
    Vector Tools
    53 |
      54 |
    • 55 |
      Conversion
      56 |
        57 |
      • 58 |
        Shapefile to KML
        59 |
      • 60 |
      • 61 |
        Shapefile to GeoTIFF
        62 |
      • 63 |
      • 64 |
        Shapefile to GeoJSON
        65 |
      • 66 |
      67 |
    • 68 |
    • 69 |
      Creation
      70 |
        71 |
      • 72 |
        Coordinates to Point Shapefile
        73 |
      • 74 |
      75 |
    • 76 |
    • 77 |
      Extraction
      78 |
        79 |
      • 80 |
        Shapefile table to text
        81 |
      • 82 |
      83 |
    • 84 |
    • 85 |
      Spatial Analysis
      86 |
        87 |
      • 88 |
        Re-Project Shapefile
        89 |
      • 90 |
      • 91 |
        Buffer Shapefile
        92 |
      • 93 |
      • 94 |
        Point inside Shapefile
        95 |
      • 96 |
      97 |
    • 98 |
    99 |
  • 100 |
101 |
102 |
103 |
104 |
105 |
    106 |
  • 107 |
    Raster Tools
    108 |
      109 |
    • 110 |
      Conversion
      111 |
        112 |
      • 113 |
        GeoTIFF to KML
        114 |
      • 115 |
      • 116 |
        GeoTIFF to point Shp
        117 |
      • 118 |
      • 119 |
        GeoTIFF to point JSON
        120 |
      • 121 |
      122 |
    • 123 |
    • 124 |
      Spatial Analysis
      125 |
        126 |
      • 127 |
        Re-Project GeoTIFF
        128 |
      • 129 |
      • 130 |
        Clip GeoTIFF by Shapefile
        131 |
      • 132 |
      • 133 |
        Change GeoTIFF Resolution
        134 |
      • 135 |
      136 |
    • 137 |
    • 138 |
      Data Management
      139 |
        140 |
      • 141 |
        Add Color on GeoTIFF
        142 |
      • 143 |
      144 |
    • 145 |
    146 |
  • 147 |
148 |
149 |
150 |
151 |
152 |
    153 |
  • 154 |
    netCDF Tools
    155 |
      156 |
    • 157 |
      Conversion
      158 |
        159 |
      • 160 |
        netCDF to GeoTIFF
        161 |
      • 162 |
      • 163 |
        netCDF to GeoJSON
        164 |
      • 165 |
      166 |
    • 167 |
    • 168 |
      Extraction
      169 |
        170 |
      • 171 |
        netCDF dump to text
        172 |
      • 173 |
      • 174 |
        netCDF header to text
        175 |
      • 176 |
      177 |
    • 178 |
    179 |
  • 180 |
181 |
182 |
183 |
184 | 185 | 212 | 213 | {% include 'footer.html' %} -------------------------------------------------------------------------------- /giscube_app/templates/tools/ncdump_header.html: -------------------------------------------------------------------------------- 1 | 2 | 28 | 29 | 30 | 41 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/ncdump_whole_netcdf.html: -------------------------------------------------------------------------------- 1 | 2 | 28 | 29 | 30 | 41 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/netcdf_to_geojson.html: -------------------------------------------------------------------------------- 1 | 2 | 54 | 55 | 56 | 94 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/netcdf_to_geotiff.html: -------------------------------------------------------------------------------- 1 | 2 | 54 | 55 | 56 | 94 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/point_inside_shapefile.html: -------------------------------------------------------------------------------- 1 | {% load shp_dict %} 2 | 3 | 4 | 34 | 35 | 36 | 48 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/re_project_geotiff.html: -------------------------------------------------------------------------------- 1 | {% load tif_dict %} 2 | 3 | 4 | 35 | 36 | 48 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/re_project_shapefile.html: -------------------------------------------------------------------------------- 1 | {% load shp_dict %} 2 | 3 | 4 | 35 | 36 | 48 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/shp_to_json.html: -------------------------------------------------------------------------------- 1 | {% load shp_dict %} 2 | 3 | 34 | 35 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/shp_to_kml.html: -------------------------------------------------------------------------------- 1 | {% load shp_dict %} 2 | 3 | 29 | 30 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/shp_to_tif.html: -------------------------------------------------------------------------------- 1 | {% load shp_dict %} 2 | 3 | 57 | 58 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/tif_to_point_json.html: -------------------------------------------------------------------------------- 1 | {% load tif_dict %} 2 | 3 | 4 | 35 | 36 | 52 | -------------------------------------------------------------------------------- /giscube_app/templates/tools/tif_to_point_shp.html: -------------------------------------------------------------------------------- 1 | {% load tif_dict %} 2 | 3 | 4 | 35 | 36 | 52 | -------------------------------------------------------------------------------- /giscube_app/templatetags/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/giscube_app/templatetags/__init__.py -------------------------------------------------------------------------------- /giscube_app/templatetags/extract_shp_table.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | ''' 4 | Project: Geothon (https://github.com/MBoustani/Geothon) 5 | File: Vector/export_shp_att_csv.py 6 | Description: This code exports Shapefile attribute table to csv file 7 | Author: Maziyar Boustani (github.com/MBoustani) 8 | ''' 9 | import csv 10 | 11 | try: 12 | import ogr 13 | except ImportError: 14 | from osgeo import ogr 15 | 16 | def extract_shp_table(shp_file_name, csv_file_name): 17 | #set the driver to ESRI Shapefiel 18 | driver = ogr.GetDriverByName('ESRI Shapefile') 19 | 20 | #open shapefile 21 | shp_datasource = driver.Open(shp_file_name) 22 | 23 | #get shapefile layer 24 | layer = shp_datasource.GetLayerByIndex(0) 25 | 26 | #get shapefile layer definition 27 | layer_defn = layer.GetLayerDefn() 28 | 29 | #get number of fields(columns) from shapefile attribute table 30 | num_field_col = layer_defn.GetFieldCount() 31 | 32 | #create csv file to store shapefile attribute table 33 | with open(csv_file_name, 'wb') as csv_file: 34 | writer = csv.writer(csv_file) 35 | #store field header 36 | field_name = [] 37 | for field in range(num_field_col): 38 | field_name.append(layer_defn.GetFieldDefn(field).GetName()) 39 | writer.writerow(field_name) 40 | 41 | #store attribute from each feature 42 | num_feature = layer.GetFeatureCount() 43 | for each in range(num_feature): 44 | feautre = layer.GetFeature(each) 45 | feautre_name = [] 46 | for i in range(num_field_col): 47 | feautre_name.append(feautre.GetFieldAsString(i)) 48 | writer.writerow(feautre_name) 49 | -------------------------------------------------------------------------------- /giscube_app/templatetags/nc_dict.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | 3 | register = template.Library() 4 | 5 | @register.filter(name='file_name') 6 | def file_name(dict): 7 | return dict['file_name'] 8 | 9 | @register.filter(name='all_variables_info') 10 | def all_variables_info(dict): 11 | return dict['all_variables_info'] 12 | 13 | @register.filter(name='var_name') 14 | def var_name(dict): 15 | return dict.keys()[0] 16 | 17 | @register.filter(name='attributes') 18 | def attributes(dict): 19 | info = [] 20 | for each in dict: 21 | for att in dict[each]: 22 | info.append('{0}: {1}'.format(att, dict[each][att])) 23 | return info -------------------------------------------------------------------------------- /giscube_app/templatetags/netcdf_dict.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | 3 | register = template.Library() 4 | 5 | @register.filter(name='file_name') 6 | def file_name(dict): 7 | return dict['file_name'] -------------------------------------------------------------------------------- /giscube_app/templatetags/re-project.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | 3 | register = template.Library() 4 | 5 | @register.filter(name='re_poject_vector') 6 | def re_poject_vector(lists): 7 | print lists 8 | #return dict['file_name'] 9 | 10 | @register.filter(name='file_format') 11 | def re_rpoject_raster(dict): 12 | return dict['file_format'] 13 | -------------------------------------------------------------------------------- /giscube_app/templatetags/shp_dict.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | 3 | register = template.Library() 4 | 5 | @register.filter(name='file_name') 6 | def file_name(dict): 7 | return dict['file_name'] 8 | 9 | @register.filter(name='file_format') 10 | def file_format(dict): 11 | return dict['file_format'] 12 | 13 | @register.filter(name='num_layer') 14 | def num_layer(dict): 15 | return dict['num_layer'] 16 | 17 | @register.filter(name='layer_name') 18 | def layer_name(dict): 19 | return dict['layer_name'] 20 | 21 | @register.filter(name='number_of_feature') 22 | def number_of_feature(dict): 23 | return dict['number_of_feature'] 24 | 25 | @register.filter(name='layer_type') 26 | def layer_type(dict): 27 | return dict['layer_type'] 28 | 29 | @register.filter(name='layer_spatial_reference') 30 | def layer_spatial_reference(dict): 31 | return dict['layer_spatial_reference'] 32 | 33 | @register.filter(name='layer_extend') 34 | def layer_extend(dict): 35 | return dict['layer_extend'] -------------------------------------------------------------------------------- /giscube_app/templatetags/tif_dict.py: -------------------------------------------------------------------------------- 1 | from django import template 2 | 3 | register = template.Library() 4 | 5 | @register.filter(name='file_name') 6 | def file_name(dict): 7 | return dict['file_name'] 8 | 9 | @register.filter(name='file_format') 10 | def file_format(dict): 11 | return dict['file_format'] 12 | 13 | @register.filter(name='layer_name') 14 | def layer_name(dict): 15 | return dict['layer_name'] 16 | 17 | @register.filter(name='num_band') 18 | def num_layer(dict): 19 | return dict['num_band'] 20 | 21 | @register.filter(name='raster_x_y_size') 22 | def raster_x_y_size(dict): 23 | return dict['raster_x_y_size'] 24 | 25 | @register.filter(name='raster_projection') 26 | def number_of_feature(dict): 27 | return dict['raster_projection'] 28 | 29 | @register.filter(name='raster_geotransform') 30 | def layer_type(dict): 31 | return dict['raster_geotransform'] 32 | 33 | @register.filter(name='raster_origin') 34 | def layer_spatial_reference(dict): 35 | return dict['raster_origin'] 36 | 37 | @register.filter(name='raster_pixle_size') 38 | def layer_extend(dict): 39 | return dict['raster_pixle_size'] -------------------------------------------------------------------------------- /giscube_app/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, url 2 | from giscube_app import views 3 | 4 | urlpatterns = patterns('', 5 | url(r'resource/(?P\S+)/$', views.data_resource, name='resource'), 6 | url(r'^$', views.data_resource, name='resource'), 7 | url(r'resource$', views.data_resource, name='resource'), 8 | url(r'information$', views.data_information, name = 'information'), 9 | url(r'visualiser$', views.data_visualiser, name = 'visualiser'), 10 | url(r'tools$', views.tools, name = 'tools'), 11 | ) -------------------------------------------------------------------------------- /giscube_app/views.py: -------------------------------------------------------------------------------- 1 | import glob, os 2 | from os.path import isfile 3 | from django.shortcuts import render, render_to_response 4 | from django.template import RequestContext 5 | from django.http import HttpResponseRedirect 6 | from django.core.urlresolvers import reverse 7 | 8 | from giscube.config import MEDIA_ROOT, MEDIA_URL 9 | 10 | from giscube_app.models import Document 11 | from giscube_app.forms import DocumentForm 12 | 13 | from giscube_app.scripts.open_file import open_shp_file, open_tif_file 14 | from giscube_app.scripts.metadata import run_shp_info 15 | from giscube_app.scripts.metadata import run_tif_info 16 | from giscube_app.scripts.what_file import what_format 17 | from giscube_app.scripts.conversion import get_geojson 18 | from giscube_app.scripts.metadata import get_nc_metadata, get_hdf_metadata 19 | from giscube_app.scripts.gtif_to_tile import create_gtif 20 | 21 | #resource page 22 | def data_resource(request, uploaded=''): 23 | notification = "" 24 | ALL_FILES = [each for each in os.listdir(MEDIA_ROOT+MEDIA_URL)] 25 | UPLODED_FILES = [] 26 | for each in ALL_FILES: 27 | file_format = what_format(MEDIA_ROOT+MEDIA_URL+each) 28 | print file_format 29 | if each.split(".")[-1]=="shp": 30 | UPLODED_FILES.append(each) 31 | if each.split(".")[-1]=="shx": 32 | UPLODED_FILES.append(each) 33 | if each.split(".")[-1]=="dbf": 34 | UPLODED_FILES.append(each) 35 | if each.split(".")[-1]=="prj": 36 | UPLODED_FILES.append(each) 37 | elif file_format == "LIBKML" or file_format=="Kml Super Overlay": 38 | UPLODED_FILES.append(each) 39 | elif file_format == "GeoTIFF": 40 | UPLODED_FILES.append(each) 41 | elif file_format == "GeoJSON": 42 | UPLODED_FILES.append(each) 43 | elif file_format == "Network Common Data Format": 44 | UPLODED_FILES.append(each) 45 | elif file_format == "NetCDF": 46 | UPLODED_FILES.append(each) 47 | elif file_format == "Hierarchical Data Format Release 4": 48 | UPLODED_FILES.append(each) 49 | elif file_format == "Hierarchical Data Format Release 5": 50 | UPLODED_FILES.append(each) 51 | elif each.split(".")[-1] == "txt" or each.split(".")[-1] == "text" or each.split(".")[-1] == "csv" or each.split(".")[-1] == "ascii": 52 | UPLODED_FILES.append(each) 53 | if request.method == 'POST': 54 | form = DocumentForm(request.POST, request.FILES) 55 | if form.is_valid(): 56 | newdoc = Document(docfile = request.FILES['docfile']) 57 | uploaded_file_name = newdoc.docfile.name 58 | newdoc.save() 59 | 60 | return HttpResponseRedirect('/resource/{0}'.format(uploaded_file_name)) 61 | else: 62 | form = DocumentForm() 63 | 64 | documents = Document.objects.all() 65 | if uploaded.split('.')[-1] == 'shp': 66 | file_name_without_ext = uploaded.replace('.{0}'.format(uploaded.split('.')[-1]),'') 67 | shx_file = "{0}{1}{2}.shx".format(MEDIA_ROOT, MEDIA_URL, file_name_without_ext) 68 | if os.path.isfile(shx_file) == False: 69 | notification = 'Please upload files below to complete Shapefile:\n{0}.shx{0}.dbf{0}.prj'.format(file_name_without_ext) 70 | return render_to_response( 71 | 'data_resource/index.html', 72 | {'documents': documents, 'form': form, 'UPLODED_FILES': UPLODED_FILES, 'notification':notification}, 73 | context_instance=RequestContext(request) 74 | ) 75 | 76 | #information page 77 | def data_information(request): 78 | os.chdir(MEDIA_ROOT + MEDIA_URL) 79 | shp_file_name = [each for each in glob.glob("*.shp") ] 80 | shps_info = [] 81 | shp_error = "No Shapefile" 82 | tif_error = "No GeoTIFF" 83 | nc_error = "No netCDF" 84 | hdf_error = "No HDF" 85 | for name in shp_file_name: 86 | if open_shp_file(name): 87 | shps_info.append(run_shp_info(name)) 88 | shp_error = "" 89 | else: 90 | shp_error = "Cannot open shapfile." 91 | break 92 | 93 | tif_file_name = [each for each in glob.glob("*.tif") ] 94 | tifs_info = [] 95 | for name in tif_file_name: 96 | if open_tif_file(name): 97 | tifs_info.append(run_tif_info(name)) 98 | tif_error = "" 99 | else: 100 | tif_error = "Cannot open tif file." 101 | break 102 | 103 | nc_file_name = [each for each in glob.glob("*.nc") ] 104 | ncs_metadata = [] 105 | for name in nc_file_name: 106 | if get_nc_metadata(name): 107 | ncs_metadata.append(get_nc_metadata(name)) 108 | nc_error = "" 109 | else: 110 | nc_error = "Cannot open netCDF file." 111 | break 112 | 113 | hdf_file_name = [each for each in glob.glob("*.he5") ] 114 | hdfs_metadata = [] 115 | for name in hdf_file_name: 116 | if get_hdf_metadata(name): 117 | hdfs_metadata.append(get_hdf_metadata(name)) 118 | hdf_error = "" 119 | else: 120 | hdf_error = "Cannot open HDF file." 121 | break 122 | 123 | context = {'shps_info': shps_info, 124 | 'tifs_info': tifs_info, 125 | 'ncs_metadata':ncs_metadata, 126 | 'hdfs_metadata':hdfs_metadata, 127 | 'shp_error':shp_error, 128 | 'tif_error':tif_error, 129 | 'nc_error':nc_error, 130 | 'hdf_error':hdf_error 131 | } 132 | 133 | return render(request, 'data_information/index.html', context) 134 | 135 | #visualiser page 136 | def data_visualiser(request): 137 | os.chdir(MEDIA_ROOT + MEDIA_URL) 138 | jsons = [] 139 | geotifs = [] 140 | shp_error = "" 141 | tif_error = "" 142 | shp_file_name = [each for each in glob.glob("*.shp")] #TODO: Use GDLA file format to recognize shapefiles, not with parsing 143 | gtif_file_name = [each for each in glob.glob("*.tif")] #TODO: Use GDLA file format to recognize geotif, not with parsing 144 | json_file_name = [each for each in glob.glob("*.json")] 145 | 146 | #add all GeoJSON to jsons 147 | for json in json_file_name: 148 | jsons.append(json.split(".json")[0]) 149 | 150 | for name in shp_file_name: 151 | if open_shp_file(name): 152 | json_name = get_geojson(name) 153 | if json_name: 154 | jsons.append(json_name.split(".json")[0]) 155 | shp_error = "" 156 | else: 157 | shp_error = "Cannot open shapfile." 158 | break 159 | 160 | for name in gtif_file_name: 161 | if open_tif_file(name): 162 | if os.path.exists('{0}{1}'.format(MEDIA_ROOT, MEDIA_URL) + name.split(".tif")[0]): 163 | geotifs.append(name.split(".tif")[0]) 164 | tif_error = "" 165 | else: 166 | geotif_folder = create_gtif(name) 167 | geotifs.append(geotif_folder) 168 | tif_error = "" 169 | else: 170 | tif_error = "Cannot open GeoTIFF." 171 | break 172 | 173 | context = {'jsons':jsons, 'geotifs':geotifs, 'shp_error':shp_error, 'tif_error':tif_error} 174 | return render(request, 'data_visualiser/index.html', context) 175 | 176 | #tools page 177 | def tools(request): 178 | os.chdir(MEDIA_ROOT + MEDIA_URL) 179 | shp_file_name = [each for each in glob.glob("*.shp") ] 180 | gtif_file_name = [each for each in glob.glob("*.tif")] 181 | nc_file_name = [each for each in glob.glob("*.nc")] 182 | text_file_name = [each for each in glob.glob("*.txt") ] + [each for each in glob.glob("*.text") ] 183 | shps_info = [] 184 | tiffs_info = [] 185 | ncs_metadata = [] 186 | text_info = [] 187 | for name in shp_file_name: 188 | if open_shp_file(name): 189 | shps_info.append(run_shp_info(name)) 190 | for name in gtif_file_name: 191 | if open_tif_file(name): 192 | tiffs_info.append(run_tif_info(name)) 193 | for name in nc_file_name: 194 | if open_tif_file(name): 195 | nc_metadata = get_nc_metadata(name) 196 | ncs_metadata.append(nc_metadata) 197 | nc_error = "" 198 | else: 199 | nc_error = "Cannot open netCDF." 200 | break 201 | for name in text_file_name: 202 | text_info.append(name) 203 | context = {'shps_info': shps_info, 'tiffs_info':tiffs_info, 'ncs_metadata':ncs_metadata, 'text_file_name':text_file_name} 204 | 205 | return render(request, 'tools/index.html', context) 206 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "giscube.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /vagrant.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MBoustani/GISCube/dabb59c5977f97fb427afc4cdcd9b1a921784734/vagrant.zip --------------------------------------------------------------------------------