O'Reilly logo

Python Geospatial Development - Second Edition by Erik Westra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding features

We'll next implement the ability to add a new feature. To do this, we'll put an Add Feature button onto the edit shapefile view. Clicking on this button will call the "edit feature" URL, but without a feature ID. We'll then modify the edit feature view so that if no feature ID is given a new Feature object is created.

Open the editor application's views.py module, find the edit_shapefile() function, and add the following highlighted lines to this function:

def editshapefile(request, shapefile_id):
    try:
        shapefile = Shapefile.objects.get(id=shapefile_id)
    except Shapefile.DoesNotExist:
        raise Http404

    tms_url = "http://"+request.get_host()+"/tms/"
    find_feature_url = "http://" + request.get_host() \
                     + "/editor/find_feature"
 add_feature_url ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required