Showing posts from September, 2016

CORS with Geoserver 2.9.0 and Tomcat

How to enable CORS on your Geoserver 2.9.0 running on Tomcat. This is taken directly from the tomcat homepage Update to tomcat 8 add the following code to your  web.xml  file then stop/start the tomcat process service tomcat stop service tomcat start <filter> <filter-name>CorsFilter</filter-name> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> <init-param> <param-name></param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.allowed.methods</param-name> <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value> </init-param> <init-param> <param-name>cors.allowed.headers</param-name> <param-value>Content-T

Using Django to create a point GeoJSON feature from the centroid of a polygon

A practical example showing how to use geoDjango geospatial functions to create the centroid of a polygon, returning a GeoJSON dataset that includes all the attributes of the original polygon feature excluding the original  geometry. Why exclude the original geometry you are probably asking yourself?  Simple, the response already will include each individual geometry representing the original so we do not want it to be duplicated in the resonse. Libraries used: Django Rest Framework to server up the response but you could of course use simple the Django response as well. Python GeoJSON to create the features.   How to use it: You will need to hook up your Django URLs to actually use this new view function.  You will only need to pass in a unique_id value to return a single point centroid from your input polygon feature. url ( r'^getcenter/(?P<unique_id> [0-9]+ /$' , get_room_center, name='centroid'),