Showing posts from 2016

How to create Django translations for django-rosetta from a model field

How to create Django translations from a model field for django-rosetta? I am using Django-Rosetta to handle all of my project translations.  Unfortunately I have only one model and one field of data that needs translation, the name of the POI.  To get around this I have created a little script to query my Django Database directly to deliver the list of names to be translated.  The output is a new html file with "trans" tags.  This html file is then placed in my templates folder so that "makemessages" can find the file and mark them for translation. Anytime I want to update this I can run this script and bingo, new template file and new translations. Note to self:  When adding msgid and msgstr  by hand the command "makemessages" will remove them in the .po file every time the command is called.

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'),

Geoserver slice string values using SLD for label manipulation

I have an attribute column in my PostGIS polygon table and want to only show the first 2 characters of this text field on my label using SLD in Geoserver .  My goal is to place the label at the center of the polygon so here it goes in SLD xml syntax as usual very verbose and ugly. <TextSymbolizer>             <Geometry>               <ogc:Function name="centroid">                 <ogc:PropertyName>geom</ogc:PropertyName>               </ogc:Function>             </Geometry>           <Label>               <ogc:Function name="strSubstring">                   <ogc:PropertyName>short_name</ogc:PropertyName>                   <ogc:Function name="parseInt">                     <ogc:Literal>0</ogc:Literal>                   </ogc:Function>                   <ogc:Function name="parseInt">                                                   <

Goals for 2016

This year I want to start out with a bang and what better way to start the year off right than setting up some goals for 2016.  I think 5 goals should be reasonalble to achieve. Goals 2016 Do more Django coding Learn better Javascript best practises Write more blog posts Complete two spare time projects for fun lets check this out again in January 2016 and see what gets done. cheers                                                                                                                                                                                                                                             

Python Geospatial Analysis Cookbook now available

Python Geospatial Analysis Cookbook Well almost 1 year has past and my book is finally available for purchase.  For those of you visiting this blog you habe 2 awesome choices to get the book at a great discount. Exclusive deal 50% off with this code: Packt is also offering a great deal to get my book and many more at only 5$ !! click below