Disclaimer: The idea came from this blog . So, what's the difference? I'm using Windows. cURL should be installed already. If you have lots of tables in your database that you wanted to publish in GeoServer, you can use this method. Just prepare a list of tables (separated by new line) you want to publish in a text file format. Before proceeding in publishing layers, you need to setup a workspace and store in your GeoServer first. Although this can be done using cURL and REST API, but it is more convenient in that way. After a minute.... :D :D Create ".bat" file Use the code below but (of course) change the necessary inputs for /f %%a in ( <list of tables you want to publish> .txt) do curl -v -u <username> : <password> -XPOST -H "Content-type: text/xml" -d "<featureType><name>%%a</name></featureType>" http://localhost:8080/geoserver/rest/workspaces/ <name of workspace> /datastores/...
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, built upon the foundations of progressive enhancement, that adds all of these advanced features to any HTML table. I've been using this plug-in for almost every project that I'm involve with. It has a built-in search, sorting and pagination facility. Less hassle and simple to implement specially in dealing with huge datasets such as 100,000+ or even millions. It's UI can be in Bootstrap, among others. Implementing it in Django requires proper format, it should follow the required structure of JSON and the table itself. Django views.py and urls.py Create a function in views.py that will handle sorting, searching and pagination of your table. To start, In your HTML file. Some common error encountered is on columns, make sure the index are properly matched!
The code below automatically loads the shapefile found in a certain directory into a PostgreSQL database within a given interval(in this example 2 minutes). Downside (in which I'm trying to figure out): What if the filename of the shapefile changes? Anyway, this suits of what I need right now. __author__ = 'Matt' import os from django.db import connection from django.contrib.gis.utils import LayerMapping from .models import FloodHazard import datetime import time import logging from apscheduler.scheduler import Scheduler logging.basicConfig() # Start the scheduler sched = Scheduler() sched.daemonic = False sched.start() #ogrinspect evidensapp/data/flood_hazard/FloodHazard.shp FloodHazard --srid=32651 --mapping --multi # Auto-generated `LayerMapping` dictionary for FloodHazard model floodhazard_mapping = { 'hazard': 'Hazard', 'date_field': 'Date_', 'geom': 'MULTIPOLYGON' } bound_shape = os.path.abspath(os....
Comments
Post a Comment
Feel free to ask, suggest and comment regarding this post/blog. You can also contact me through e-mail, just always use the contact page. Thank you for visiting this blog.