Giter Site home page Giter Site logo

Comments (29)

brutasse avatar brutasse commented on May 30, 2024

Hey,

Please, the issue tracker is used for actual bugs in the app, not
support so don't open issues for usage questions. Either use the
Github contact form or /msg me on IRC, I'm brutasse on freenode.

As for your question, if you want to draw any number and type of
features on a single map, you need to use the GeometryCollectionWidget
and maybe unpack / parse the features in your form's clean() method.

Regarding switching the base layer, the map widget is standard
OpenLayers code so you can safely add and remove layers with some
custom javascript code. Look at the MapWidget object with Firebug, you
can play with its map attribute.

On Tue, Jun 14, 2011 at 11:39 AM, KasperaskyMe
[email protected]
wrote:

First of all , a brilliant application , and thank you for all the help till now .

This is my forms.py

from django import forms
from openmaps.models import Open_Layers
from django.contrib.admin import widgets
import floppyforms as forms
class PointWidget(forms.gis.PointWidget, forms.gis.BaseGMapWidget):
   pass
class MultiPointWidget(forms.gis.MultiPointWidget,forms.gis.BaseGMapWidget):
   pass
class LineStringWidget(forms.gis.LineStringWidget,forms.gis.BaseGMapWidget):
   pass
class PolygonWidget(forms.gis.PolygonWidget,forms.gis.BaseGMapWidget):
   pass
class MultiPolygonWidget(forms.gis.MultiPolygonWidget,forms.gis.BaseGMapWidget):
   pass
class GeoForm(forms.Form):
   point = forms.gis.PointField()
   multipoint = forms.gis.MultiPointField()
   line = forms.gis.LineStringField()
   poly = forms.gis.PolygonField()
   multipoly= forms.gis.MultiPolygonField()

According to this , all the points , multipoints , line etc load in separate openlayers maps , but in the same page . Is it by anychance possible to put in all the geometries in one map . And also , allow to change between maps like openlayers , osm , google maps using layerswitcher .

Reply to this email directly or view it on GitHub:
#14

from django-floppyforms.

 avatar commented on May 30, 2024

Hmm ok . Tried contacting you over the message , but won't it be considered an issue that its generating the latitude and longitude of the point or line or polygon ? As in , there is no API . I can use default_lat and default_lon to send long , lat values , but this variables are to be send to template side , but can't be received by the form .

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

What do you mean by "it's generating the latitude and longitude"? What does "it" refer to? What API is missing, that prevents you from displaying a map widget focused on the area you want?

from django-floppyforms.

 avatar commented on May 30, 2024

ok I will explain in detail .

I am basically trying to show an openlayers/googlemaps/OSM , which would
allow me to do this :

  1. Store the type of geometry
  2. Store the lat , long , geom
  3. And for every type of geom , a new table will be created in my db .
  4. When I retrieve that table from the db , it should display on the map ..

I am able to do 1 and 3 .
In 2 , I can get the geom using your api .
Usually point.lat() and point.lon() , or openlayers.lat() , openlayers.lon()
gives the latitude and longtitude of the point , or the set of points that I
have marked over the map . But its not giving here . Thats obviously because
your api ( data that is retrieved when I point is marked and submitted)
doesn't return it . May be it does , but I am not sure how to retrieve it .

The other thing is mapping any data ( shp files to kml files ) from the
database to be mapped on an openlayers/google base layer .

I am using databrowse admin provided by geodjango . But that is not really
helping my cause as it only allows one object (one row) to be seen per map
.

Thus , anyway django-floppy forms widget can be used to do this .

Any help is much appreciated . I am sure I am bugging you with my noob-ism ,
but its an open source tool , and once its done it can itself be a good
addition developed mostly on django floppy forms .

On Wed, Jun 15, 2011 at 3:04 PM, brutasse <
[email protected]>wrote:

What do you mean by "it's generating the latitude and longitude"? What does
"it" refer to? What API is missing, that prevents you from displaying a map
widget focused on the area you want?

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

 avatar commented on May 30, 2024

Hi .
A small last help . Geometry collection widget is returning values something
similar to this
"GEOMETRYCOLLECTION (POINT (-8.9648437500000000 -4.1308593750000000), POINT
(2.0214843750000000 -2.6367187500000000), POINT (-1.4062500000000000
-11.1621093750000000), POINT (-11.9531250000000000,-10.8984375000000000),
POLYGON ((-21.6210937500000000 1.8457031250000000,2.4609375000000000
2.1972656250000000, -18.9843750000000000 -3.6914062500000000,
-22.6757812500000000 -3.3398437500000000, -22.1484375000000000
-2.6367187500000000, -21.6210937500000000 1.8457031250000000)),LINESTRING
(-11.9531250000000000 11.3378906250000000, 7.7343750000000000
11.5136718750000000, 12.3046875000000000 2.5488281250000000,
12.2167968750000000 1.6699218750000000, 14.5019531250000000
3.9550781250000000))"

Which is obvious . Is it by anychance possible to parse through the data ,
and form lists so as to store it in the database ?

On Wed, Jun 15, 2011 at 3:19 PM, Satyajit Sarangi <[email protected]

wrote:

ok I will explain in detail .

I am basically trying to show an openlayers/googlemaps/OSM , which would
allow me to do this :

  1. Store the type of geometry
  2. Store the lat , long , geom
  3. And for every type of geom , a new table will be created in my db .
  4. When I retrieve that table from the db , it should display on the map ..

I am able to do 1 and 3 .
In 2 , I can get the geom using your api .
Usually point.lat() and point.lon() , or openlayers.lat() ,
openlayers.lon() gives the latitude and longtitude of the point , or the set
of points that I have marked over the map . But its not giving here . Thats
obviously because your api ( data that is retrieved when I point is marked
and submitted) doesn't return it . May be it does , but I am not sure how to
retrieve it .

The other thing is mapping any data ( shp files to kml files ) from the
database to be mapped on an openlayers/google base layer .

I am using databrowse admin provided by geodjango . But that is not really
helping my cause as it only allows one object (one row) to be seen per map
.

Thus , anyway django-floppy forms widget can be used to do this .

Any help is much appreciated . I am sure I am bugging you with my noob-ism
, but its an open source tool , and once its done it can itself be a good
addition developed mostly on django floppy forms .

On Wed, Jun 15, 2011 at 3:04 PM, brutasse <
[email protected]>wrote:

What do you mean by "it's generating the latitude and longitude"? What
does "it" refer to? What API is missing, that prevents you from displaying a
map widget focused on the area you want?

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

Yes, this data is parseable and you can save it :). Say you have a form with a geometry field:

class GeoForm(forms.Form):
geom = forms.GeometryCollectionField() # maybe with a custom widget

In your view, you would do something like:

def my_view(request):
if request.method == 'POST':
form = GeoForm(data=request.POST)
if form.is_valid():
geom_collection = form.cleaned_data['geom']
# do stuff with the geom colleczion
else:
form = GeoForm()
return render_to_response('template.html', {'form': form})

So, in form.cleaned_data, you get a django.contrib.gis.geos.GEOSGeometry [0] object. If you have a model with a GeometryCollection field, you can directly assign the form data to it and save the model to the database.

Does that help? I guess that addresses the point 2) from your previous message as well...

[0] https://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/#geosgeometry

from django-floppyforms.

 avatar commented on May 30, 2024

Yes it does . That pretty much addresses all my solutions . Thanks a lot . I
shall keep you updated on the project . You can fork it once its up :)

On Wed, Jun 15, 2011 at 11:42 PM, brutasse <
[email protected]>wrote:

Yes, this data is parseable and you can save it :). Say you have a form
with a geometry field:

class GeoForm(forms.Form):
geom = forms.GeometryCollectionField() # maybe with a custom widget

In your view, you would do something like:

def my_view(request):
if request.method == 'POST':
form = GeoForm(data=request.POST)
if form.is_valid():
geom_collection = form.cleaned_data['geom']
# do stuff with the geom colleczion
else:
form = GeoForm()
return render_to_response('template.html', {'form': form})

So, in form.cleaned_data, you get a django.contrib.gis.geos.GEOSGeometry
[0] object. If you have a model with a GeometryCollection field, you can
directly assign the form data to it and save the model to the database.

Does that help? I guess that addresses the point 2) from your previous
message as well...

[0]
https://docs.djangoproject.com/en/dev/ref/contrib/gis/geos/#geosgeometry

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

Totally, let me know when it's up :)

from django-floppyforms.

 avatar commented on May 30, 2024

Hey there . The project I have been working on is going quite well . Had a
small doubt . After I save the data using django floppy forms and its
Madwidget.js . Can I use the same to view the data that I just saved ? As in
, view the GeometryCollection data that I just saved on an openlayers map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

Sure, you can use the MapWidget just to visualize the data. I usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form that
has this readonly widget:

form = ReadOnlyForm(data={'polygon': what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though :)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite well . Had a
small doubt . After I save the data using django floppy forms and its
Madwidget.js . Can I use the same to view the data that I just saved ? As in
, view the GeometryCollection data that I just saved on an openlayers map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:
#14 (comment)

from django-floppyforms.

 avatar commented on May 30, 2024

But what if the person wants to edit the data ? As in , lets say he has
created a geometry collection field of data . And he has saved it in the
database . now he wants to view the data again , and see if he got it right
. if he hasn't , he has to edit the data . How does he edit the data ?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form that
has this readonly widget:

form = ReadOnlyForm(data={'polygon': what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though :)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite well . Had
a
small doubt . After I save the data using django floppy forms and its
Madwidget.js . Can I use the same to view the data that I just saved ? As
in
, view the GeometryCollection data that I just saved on an openlayers map
?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

 avatar commented on May 30, 2024

I am assuming I have to keep options[modfiable] = True for that to happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say he has
created a geometry collection field of data . And he has saved it in the
database . now he wants to view the data again , and see if he got it right
. if he hasn't , he has to edit the data . How does he edit the data ?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form that
has this readonly widget:

form = ReadOnlyForm(data={'polygon': what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though :)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite well . Had
a
small doubt . After I save the data using django floppy forms and its
Madwidget.js . Can I use the same to view the data that I just saved ?
As in
, view the GeometryCollection data that I just saved on an openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say he has
created a geometry collection field of data . And he has saved it in the
database . now he wants to view the data again , and see if he got it right
. if he hasn't , he has to edit the data . How does he edit the data ?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
                        forms.gis.BaseOsmWidget):
   template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
   polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form that
has this readonly widget:

form = ReadOnlyForm(data={'polygon': what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though :)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite well . Had
a
small doubt . After I save the data using django floppy forms and its
Madwidget.js . Can I use the same to view the data that I just saved ?
As in
, view the GeometryCollection data that I just saved on an openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:
#14 (comment)

from django-floppyforms.

 avatar commented on May 30, 2024

Oh this solves a lot of purpose . i can use the read only widget the apply
permissions on particular users :) . Thank you again . Phew . Never knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say he has
created a geometry collection field of data . And he has saved it in the
database . now he wants to view the data again , and see if he got it
right
. if he hasn't , he has to edit the data . How does he edit the data ?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though :)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite well .
Had
a
small doubt . After I save the data using django floppy forms and its
Madwidget.js . Can I use the same to view the data that I just saved
?
As in
, view the GeometryCollection data that I just saved on an openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget the apply
permissions on particular users :) . Thank you again . Phew . Never knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say he has
created a geometry collection field of data . And he has saved it in the
database . now he wants to view the data again , and see if he got it
right
. if he hasn't , he has to edit the data . How does he edit the data ?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
                        forms.gis.BaseOsmWidget):
   template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
   polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though :)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite well .
Had
a
small doubt . After I save the data using django floppy forms and its
Madwidget.js . Can I use the same to view the data that I just saved
?
As in
, view the GeometryCollection data that I just saved on an openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:
#14 (comment)

from django-floppyforms.

 avatar commented on May 30, 2024

Oh yeah . But lot of changes have to be done . The databrowse admin is a
total handicap . So I have to use django floppy forms and its Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget the
apply
permissions on particular users :) . Thank you again . Phew . Never knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say he
has
created a geometry collection field of data . And he has saved it in
the
database . now he wants to view the data again , and see if he got it
right
. if he hasn't , he has to edit the data . How does he edit the data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite well
.
Had
a
small doubt . After I save the data using django floppy forms and
its
Madwidget.js . Can I use the same to view the data that I just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

 avatar commented on May 30, 2024

This is what I did .

My template

{% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
{{ form.media }}

{% csrf_token %}
  {{form.geomcollection}}
  <p><input type="submit" value="Submit"></p>
</form>

My views

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

        LName = form.cleaned_data['LayerName']
            LDes = form.cleaned_data['LayerDescription']
        a.Layer_name=LName
                    a.Layer_desc=LDes
        a.save()

            form1 = ReadOnlyForm(data={'geomcollection': val})

        return render_to_response('some-widget.html', ({'form':form1}))

The template just shows a text box and a delete features button . I am
assuming the OpenLayers is not getting intialized . What can be the error ?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin is a
total handicap . So I have to use django floppy forms and its Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget the
apply
permissions on particular users :) . Thank you again . Phew . Never knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say he
has
created a geometry collection field of data . And he has saved it in
the
database . now he wants to view the data again , and see if he got
it
right
. if he hasn't , he has to edit the data . How does he edit the data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite
well .
Had
a
small doubt . After I save the data using django floppy forms and
its
Madwidget.js . Can I use the same to view the data that I just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

You need two separate template. One for the widget, where you put this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }} {{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

  {% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
   {{ form.media }}
 
 
   


     {% csrf_token %}

     {{form.geomcollection}}
     


   
 

My views

 if request.method == 'POST':
           form = GeoForm(request.POST)
           if form.is_valid():
           data = form.cleaned_data
                   val=form.cleaned_data['AddLayer']
                       val1=val[0]
                       val2=val[2]
                       val3=val[3]
           a=Open_Layers()
           a.geom_poly=GeometryCollection(val[0],val[1],val[3])

           LName = form.cleaned_data['LayerName']
               LDes = form.cleaned_data['LayerDescription']
           a.Layer_name=LName
                       a.Layer_desc=LDes
           a.save()

               form1 = ReadOnlyForm(data={'geomcollection': val})

           return render_to_response('some-widget.html', ({'form':form1}))

The template just shows a text box and a delete features button . I am
assuming the OpenLayers is not getting intialized . What can be the error ?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin is a
total handicap . So I have to use django floppy forms and its Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget the
apply
permissions on particular users :) . Thank you again . Phew . Never knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say he
has
created a geometry collection field of data . And he has saved it in
the
database . now he wants to view the data again , and see if he got
it
right
. if he hasn't , he has to edit the data . How does he edit the data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
                        forms.gis.BaseOsmWidget):
   template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
   polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your users
from drawing on the map. Then, in your view, instantiate a form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }} and
you're done! Make sure there's no way to re-submit the form though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite
well .
Had
a
small doubt . After I save the data using django floppy forms and
its
Madwidget.js . Can I use the same to view the data that I just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:
#14 (comment)

from django-floppyforms.

 avatar commented on May 30, 2024

I did those changes too . Even though the map loads , the points or polygons
don't really appear . This is the error
Image corrupt or truncated:
http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=22.5,-33.75,33.75,-22.5&WIDTH=256&HEIGHT=256

On Sat, Jun 18, 2011 at 6:56 PM, brutasse <
[email protected]>wrote:

You need two separate template. One for the widget, where you put this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }} {{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

{% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
{{ form.media }}

{% csrf_token %}
 {{form.geomcollection}}
 <p><input type="submit" value="Submit"></p>

My views

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

       LName = form.cleaned_data['LayerName']
           LDes = form.cleaned_data['LayerDescription']
       a.Layer_name=LName
                   a.Layer_desc=LDes
       a.save()

           form1 = ReadOnlyForm(data={'geomcollection': val})

       return render_to_response('some-widget.html',

({'form':form1}))

The template just shows a text box and a delete features button . I am
assuming the OpenLayers is not getting intialized . What can be the error
?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <
[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin is a
total handicap . So I have to use django floppy forms and its
Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget the
apply
permissions on particular users :) . Thank you again . Phew . Never
knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say
he
has
created a geometry collection field of data . And he has saved it
in
the
database . now he wants to view the data again , and see if he
got
it
right
. if he hasn't , he has to edit the data . How does he edit the
data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your
users
from drawing on the map. Then, in your view, instantiate a form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }}
and
you're done! Make sure there's no way to re-submit the form
though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite
well .
Had
a
small doubt . After I save the data using django floppy forms
and
its
Madwidget.js . Can I use the same to view the data that I just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

The image loads fine here... It seems that it's trying to initialize
the BaseMetacartaWidget, the example I gave you was for BaseOsmWidget.
Depending on the base widget you use, you'll need to extend a
different widget template: in some-widget.html, when you do:

{% extends "floppyforms/gis/openlayers.html" %}

this is for BaseMetacartaWidget, it's likely to throw errors if you
use BaseOsmWidget. Can you check that?

If you want OpenStreetMap instead of the basic Metacarta layer, you
need to {% extend "floppyforms/gis/osm.html" %}

Same for Google Maps, you have a base google map widget and a template
to extend, "floppyforms/gis/google.html".

On Sat, Jun 18, 2011 at 3:41 PM, KasperaskyMe
[email protected]
wrote:

I did those changes too . Even though the map loads , the points or polygons
don't really appear . This is the error
Image corrupt or truncated:
http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=22.5,-33.75,33.75,-22.5&WIDTH=256&HEIGHT=256

On Sat, Jun 18, 2011 at 6:56 PM, brutasse <
[email protected]>wrote:

You need two separate template. One for the widget, where you put this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }} {{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

  {% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
   {{ form.media }}
 
 
   


     {% csrf_token %}

     {{form.geomcollection}}
     


   
 

My views

 if request.method == 'POST':
           form = GeoForm(request.POST)
           if form.is_valid():
           data = form.cleaned_data
                   val=form.cleaned_data['AddLayer']
                       val1=val[0]
                       val2=val[2]
                       val3=val[3]
           a=Open_Layers()
           a.geom_poly=GeometryCollection(val[0],val[1],val[3])

           LName = form.cleaned_data['LayerName']
               LDes = form.cleaned_data['LayerDescription']
           a.Layer_name=LName
                       a.Layer_desc=LDes
           a.save()

               form1 = ReadOnlyForm(data={'geomcollection': val})

           return render_to_response('some-widget.html',
({'form':form1}))

The template just shows a text box and a delete features button . I am
assuming the OpenLayers is not getting intialized . What can be the error
?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <
[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin is a
total handicap . So I have to use django floppy forms and its
Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget the
apply
permissions on particular users :) . Thank you again . Phew . Never
knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets say
he
has
created a geometry collection field of data . And he has saved it
in
the
database . now he wants to view the data again , and see if he
got
it
right
. if he hasn't , he has to edit the data . How does he edit the
data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
                        forms.gis.BaseOsmWidget):
   template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
   polygon = forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your
users
from drawing on the map. Then, in your view, instantiate a form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon }}
and
you're done! Make sure there's no way to re-submit the form
though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going quite
well .
Had
a
small doubt . After I save the data using django floppy forms
and
its
Madwidget.js . Can I use the same to view the data that I just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:
#14 (comment)

from django-floppyforms.

 avatar commented on May 30, 2024

OpenLayers is loading fine . Its not getting truncated , but there in
loading of the data . Don't you think I need to save the data or something
on the layer . Do an addlayer or something to get the data on the layer ?

My forms.py
class
GeometryCollectionWidget(forms.gis.GeometryCollectionWidget,forms.gis.BaseGMapWidget):
pass
class GeoForm(forms.Form):
AddLayer = forms.gis.GeometryCollectionField()
LayerName = forms.CharField()
LayerDescription = forms.CharField()

class ReadOnlyWidget(forms.gis.GeometryCollectionWidget,
forms.gis.BaseGMapWidget):
template_name = 'widget.html'

class ReadOnlyForm(forms.Form):
geomcollection = forms.gis.GeometryCollectionField(widget=ReadOnlyWidget)

My views.py

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

        LName = form.cleaned_data['LayerName']
            LDes = form.cleaned_data['LayerDescription']
        a.Layer_name=LName
                    a.Layer_desc=LDes
        a.save()

            form1 = ReadOnlyForm()
        form1.geomcollection = a.geom_poly

        return render_to_response('some-widget.html', ({'form':form1}))

And some-widget.html

{{ form.media }}
{% csrf_token %}
  {{form.geomcollection}}
  <p><input type="submit" value="Submit"></p>
</form>

On Sat, Jun 18, 2011 at 7:21 PM, brutasse <
[email protected]>wrote:

The image loads fine here... It seems that it's trying to initialize
the BaseMetacartaWidget, the example I gave you was for BaseOsmWidget.
Depending on the base widget you use, you'll need to extend a
different widget template: in some-widget.html, when you do:

{% extends "floppyforms/gis/openlayers.html" %}

this is for BaseMetacartaWidget, it's likely to throw errors if you
use BaseOsmWidget. Can you check that?

If you want OpenStreetMap instead of the basic Metacarta layer, you
need to {% extend "floppyforms/gis/osm.html" %}

Same for Google Maps, you have a base google map widget and a template
to extend, "floppyforms/gis/google.html".

On Sat, Jun 18, 2011 at 3:41 PM, KasperaskyMe
[email protected]
wrote:

I did those changes too . Even though the map loads , the points or
polygons
don't really appear . This is the error
Image corrupt or truncated:

http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=22.5,-33.75,33.75,-22.5&WIDTH=256&HEIGHT=256

On Sat, Jun 18, 2011 at 6:56 PM, brutasse <
[email protected]>wrote:

You need two separate template. One for the widget, where you put this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }} {{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

{% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
{{ form.media }}

{% csrf_token %}
 {{form.geomcollection}}
 <p><input type="submit" value="Submit"></p>

My views

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

       LName = form.cleaned_data['LayerName']
           LDes = form.cleaned_data['LayerDescription']
       a.Layer_name=LName
                   a.Layer_desc=LDes
       a.save()

           form1 = ReadOnlyForm(data={'geomcollection': val})

       return render_to_response('some-widget.html',

({'form':form1}))

The template just shows a text box and a delete features button . I am
assuming the OpenLayers is not getting intialized . What can be the
error
?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <
[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin
is a
total handicap . So I have to use django floppy forms and its
Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget
the
apply
permissions on particular users :) . Thank you again . Phew .
Never
knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no
need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that
to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets
say
he
has
created a geometry collection field of data . And he has saved
it
in
the
database . now he wants to view the data again , and see if he
got
it
right
. if he hasn't , he has to edit the data . How does he edit
the
data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using
a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon =
forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your
users
from drawing on the map. Then, in your view, instantiate a
form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon
}}
and
you're done! Make sure there's no way to re-submit the form
though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going
quite
well .
Had
a
small doubt . After I save the data using django floppy
forms
and
its
Madwidget.js . Can I use the same to view the data that I
just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

First, it looks like you're mixing tabs and spaces for indentation.
Maybe it's just the email but if this is the case, fix your
indentation and your editor.

Given that there's no error thrown by python, it's likely to be
something else. I see that you're constructing a geometry by hand and
you're using google maps. Is your initial form using google maps too?

Check the generated HTML source. You should see a textarea element,
does it contain any data?

Anyway, there are two things to change:

  • when you create a GeometryCollection, give it an "srid" argument: if
    the data comes from a google map, do GeometryCollection(val[0],
    val[1], val[2], srid=900913). If you're using the Metacarta widget,
    use srid=4326. If it's OpenStreetMap, use 900913.
  • when you create the form, pass it a "initial" dictionnary. Assigning
    the field directly will never work:

form = ReadOnlyForm(initial={"geomcollection": a.geom_poly})

Once you've done this, check again what's in the textarea in the
generated HTML. You should see something like "GEOMETRYCOLLECTION(
....)".

You don't need to do anything in JavaScript, the layer will load on its own.

On 19 Jun 2011, at 04:24, KasperaskyMe
[email protected]
wrote:

OpenLayers is loading fine . Its not getting truncated , but there in
loading of the data . Don't you think I need to save the data or something
on the layer . Do an addlayer or something to get the data on the layer ?

My forms.py
class
GeometryCollectionWidget(forms.gis.GeometryCollectionWidget,forms.gis.BaseGMapWidget):
pass
class GeoForm(forms.Form):
AddLayer = forms.gis.GeometryCollectionField()
LayerName = forms.CharField()
LayerDescription = forms.CharField()

class ReadOnlyWidget(forms.gis.GeometryCollectionWidget,
forms.gis.BaseGMapWidget):
template_name = 'widget.html'

class ReadOnlyForm(forms.Form):
geomcollection = forms.gis.GeometryCollectionField(widget=ReadOnlyWidget)

My views.py

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

       LName = form.cleaned_data['LayerName']
           LDes = form.cleaned_data['LayerDescription']
       a.Layer_name=LName
                   a.Layer_desc=LDes
       a.save()

           form1 = ReadOnlyForm()
       form1.geomcollection = a.geom_poly

       return render_to_response('some-widget.html', ({'form':form1}))

And some-widget.html

{{ form.media }}

{% csrf_token %}
 {{form.geomcollection}}
 <p><input type="submit" value="Submit"></p>

On Sat, Jun 18, 2011 at 7:21 PM, brutasse <
[email protected]>wrote:

The image loads fine here... It seems that it's trying to initialize
the BaseMetacartaWidget, the example I gave you was for BaseOsmWidget.
Depending on the base widget you use, you'll need to extend a
different widget template: in some-widget.html, when you do:

{% extends "floppyforms/gis/openlayers.html" %}

this is for BaseMetacartaWidget, it's likely to throw errors if you
use BaseOsmWidget. Can you check that?

If you want OpenStreetMap instead of the basic Metacarta layer, you
need to {% extend "floppyforms/gis/osm.html" %}

Same for Google Maps, you have a base google map widget and a template
to extend, "floppyforms/gis/google.html".

On Sat, Jun 18, 2011 at 3:41 PM, KasperaskyMe
[email protected]
wrote:

I did those changes too . Even though the map loads , the points or
polygons
don't really appear . This is the error
Image corrupt or truncated:

http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=22.5,-33.75,33.75,-22.5&WIDTH=256&HEIGHT=256

On Sat, Jun 18, 2011 at 6:56 PM, brutasse <
[email protected]>wrote:

You need two separate template. One for the widget, where you put this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }} {{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

{% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
{{ form.media }}

{% csrf_token %}
{{form.geomcollection}}
<p><input type="submit" value="Submit"></p>

My views

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

      LName = form.cleaned_data['LayerName']
          LDes = form.cleaned_data['LayerDescription']
      a.Layer_name=LName
                  a.Layer_desc=LDes
      a.save()

          form1 = ReadOnlyForm(data={'geomcollection': val})

      return render_to_response('some-widget.html',

({'form':form1}))

The template just shows a text box and a delete features button . I am
assuming the OpenLayers is not getting intialized . What can be the
error
?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <
[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin
is a
total handicap . So I have to use django floppy forms and its
Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget
the
apply
permissions on particular users :) . Thank you again . Phew .
Never
knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no
need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that
to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets
say
he
has
created a geometry collection field of data . And he has saved
it
in
the
database . now he wants to view the data again , and see if he
got
it
right
. if he hasn't , he has to edit the data . How does he edit
the
data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using
a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon =
forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your
users
from drawing on the map. Then, in your view, instantiate a
form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon
}}
and
you're done! Make sure there's no way to re-submit the form
though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going
quite
well .
Had
a
small doubt . After I save the data using django floppy
forms
and
its
Madwidget.js . Can I use the same to view the data that I
just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:
#14 (comment)

from django-floppyforms.

 avatar commented on May 30, 2024

I did check the html source . Did all the changes as you had mentioned . The
source just has the POINTS . It doesnt have lines or polygons .
Also the Mapwidget.js is throwing an error . if (features.constructor ==
Array) { . Feature is undefined . Do you think that might be the cause for
not being able to show the dict ?

And , another doubt is this .
form = ReadOnlyForm(initial={"
geomcollection": a.geom_poly})
I initialized the data like this . If I leave it at that , it gives me GEOS
error .
But if I do this after that ,
form=form1.geomcollection = a.geom_poly
It doesn't . Doesnt the initialization itself do the same as the above line
?

On Sun, Jun 19, 2011 at 10:20 AM, brutasse <
[email protected]>wrote:

First, it looks like you're mixing tabs and spaces for indentation.
Maybe it's just the email but if this is the case, fix your
indentation and your editor.

Given that there's no error thrown by python, it's likely to be
something else. I see that you're constructing a geometry by hand and
you're using google maps. Is your initial form using google maps too?

Check the generated HTML source. You should see a textarea element,
does it contain any data?

Anyway, there are two things to change:

  • when you create a GeometryCollection, give it an "srid" argument: if
    the data comes from a google map, do GeometryCollection(val[0],
    val[1], val[2], srid=900913). If you're using the Metacarta widget,
    use srid=4326. If it's OpenStreetMap, use 900913.
  • when you create the form, pass it a "initial" dictionnary. Assigning
    the field directly will never work:

form = ReadOnlyForm(initial={"geomcollection": a.geom_poly})

Once you've done this, check again what's in the textarea in the
generated HTML. You should see something like "GEOMETRYCOLLECTION(
....)".

You don't need to do anything in JavaScript, the layer will load on its
own.

On 19 Jun 2011, at 04:24, KasperaskyMe
[email protected]
wrote:

OpenLayers is loading fine . Its not getting truncated , but there in
loading of the data . Don't you think I need to save the data or
something
on the layer . Do an addlayer or something to get the data on the layer ?

My forms.py
class

GeometryCollectionWidget(forms.gis.GeometryCollectionWidget,forms.gis.BaseGMapWidget):
pass
class GeoForm(forms.Form):
AddLayer = forms.gis.GeometryCollectionField()
LayerName = forms.CharField()
LayerDescription = forms.CharField()

class ReadOnlyWidget(forms.gis.GeometryCollectionWidget,
forms.gis.BaseGMapWidget):
template_name = 'widget.html'

class ReadOnlyForm(forms.Form):
geomcollection =
forms.gis.GeometryCollectionField(widget=ReadOnlyWidget)

My views.py

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

       LName = form.cleaned_data['LayerName']
           LDes = form.cleaned_data['LayerDescription']
       a.Layer_name=LName
                   a.Layer_desc=LDes
       a.save()

           form1 = ReadOnlyForm()
       form1.geomcollection = a.geom_poly

       return render_to_response('some-widget.html',

({'form':form1}))

And some-widget.html

{{ form.media }}

{% csrf_token %}
 {{form.geomcollection}}
 <p><input type="submit" value="Submit"></p>

On Sat, Jun 18, 2011 at 7:21 PM, brutasse <
[email protected]>wrote:

The image loads fine here... It seems that it's trying to initialize
the BaseMetacartaWidget, the example I gave you was for BaseOsmWidget.
Depending on the base widget you use, you'll need to extend a
different widget template: in some-widget.html, when you do:

{% extends "floppyforms/gis/openlayers.html" %}

this is for BaseMetacartaWidget, it's likely to throw errors if you
use BaseOsmWidget. Can you check that?

If you want OpenStreetMap instead of the basic Metacarta layer, you
need to {% extend "floppyforms/gis/osm.html" %}

Same for Google Maps, you have a base google map widget and a template
to extend, "floppyforms/gis/google.html".

On Sat, Jun 18, 2011 at 3:41 PM, KasperaskyMe
[email protected]
wrote:

I did those changes too . Even though the map loads , the points or
polygons
don't really appear . This is the error
Image corrupt or truncated:

http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=22.5,-33.75,33.75,-22.5&WIDTH=256&HEIGHT=256

On Sat, Jun 18, 2011 at 6:56 PM, brutasse <
[email protected]>wrote:

You need two separate template. One for the widget, where you put
this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }} {{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

{% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
{{ form.media }}

{% csrf_token %}
{{form.geomcollection}}
<p><input type="submit" value="Submit"></p>

My views

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

      LName = form.cleaned_data['LayerName']
          LDes = form.cleaned_data['LayerDescription']
      a.Layer_name=LName
                  a.Layer_desc=LDes
      a.save()

          form1 = ReadOnlyForm(data={'geomcollection': val})

      return render_to_response('some-widget.html',

({'form':form1}))

The template just shows a text box and a delete features button . I
am
assuming the OpenLayers is not getting intialized . What can be the
error
?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <
[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin
is a
total handicap . So I have to use django floppy forms and its
Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget
the
apply
permissions on particular users :) . Thank you again . Phew .
Never
knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no
need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that
to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets
say
he
has
created a geometry collection field of data . And he has saved
it
in
the
database . now he wants to view the data again , and see if he
got
it
right
. if he hasn't , he has to edit the data . How does he edit
the
data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using
a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon =
forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your
users
from drawing on the map. Then, in your view, instantiate a
form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon
}}
and
you're done! Make sure there's no way to re-submit the form
though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going
quite
well .
Had
a
small doubt . After I save the data using django floppy
forms
and
its
Madwidget.js . Can I use the same to view the data that I
just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

The JS error is because the geometry collection is not successfully
parsed. Obviously this is blocking the rendering.

Intanciating the form with an initial dict and assigning the geometry
to the form is not the same, you need to do it the way I told you. If
it's throwing an error, it's probably that the feature you created is
not properly constructed. What error is it?

That's my last email for today, I'm going offline. You're doing things
by hand so it's hard to debug and you really need to understand what
you're doing. Try to fix the geos error, try to understand why the
MapWidget is unable to parse the geometry (use the source :)

On 19 Jun 2011, at 07:31, KasperaskyMe
[email protected]
wrote:

I did check the html source . Did all the changes as you had mentioned . The
source just has the POINTS . It doesnt have lines or polygons .
Also the Mapwidget.js is throwing an error . if (features.constructor ==
Array) { . Feature is undefined . Do you think that might be the cause for
not being able to show the dict ?

And , another doubt is this .
form = ReadOnlyForm(initial={"
geomcollection": a.geom_poly})
I initialized the data like this . If I leave it at that , it gives me GEOS
error .
But if I do this after that ,
form=form1.geomcollection = a.geom_poly
It doesn't . Doesnt the initialization itself do the same as the above line
?

On Sun, Jun 19, 2011 at 10:20 AM, brutasse <
[email protected]>wrote:

First, it looks like you're mixing tabs and spaces for indentation.
Maybe it's just the email but if this is the case, fix your
indentation and your editor.

Given that there's no error thrown by python, it's likely to be
something else. I see that you're constructing a geometry by hand and
you're using google maps. Is your initial form using google maps too?

Check the generated HTML source. You should see a textarea element,
does it contain any data?

Anyway, there are two things to change:

  • when you create a GeometryCollection, give it an "srid" argument: if
    the data comes from a google map, do GeometryCollection(val[0],
    val[1], val[2], srid=900913). If you're using the Metacarta widget,
    use srid=4326. If it's OpenStreetMap, use 900913.
  • when you create the form, pass it a "initial" dictionnary. Assigning
    the field directly will never work:

form = ReadOnlyForm(initial={"geomcollection": a.geom_poly})

Once you've done this, check again what's in the textarea in the
generated HTML. You should see something like "GEOMETRYCOLLECTION(
....)".

You don't need to do anything in JavaScript, the layer will load on its
own.

On 19 Jun 2011, at 04:24, KasperaskyMe
[email protected]
wrote:

OpenLayers is loading fine . Its not getting truncated , but there in
loading of the data . Don't you think I need to save the data or
something
on the layer . Do an addlayer or something to get the data on the layer ?

My forms.py
class

GeometryCollectionWidget(forms.gis.GeometryCollectionWidget,forms.gis.BaseGMapWidget):
pass
class GeoForm(forms.Form):
AddLayer = forms.gis.GeometryCollectionField()
LayerName = forms.CharField()
LayerDescription = forms.CharField()

class ReadOnlyWidget(forms.gis.GeometryCollectionWidget,
forms.gis.BaseGMapWidget):
template_name = 'widget.html'

class ReadOnlyForm(forms.Form):
geomcollection =
forms.gis.GeometryCollectionField(widget=ReadOnlyWidget)

My views.py

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

      LName = form.cleaned_data['LayerName']
          LDes = form.cleaned_data['LayerDescription']
      a.Layer_name=LName
                  a.Layer_desc=LDes
      a.save()

          form1 = ReadOnlyForm()
      form1.geomcollection = a.geom_poly

      return render_to_response('some-widget.html',

({'form':form1}))

And some-widget.html

{{ form.media }}

{% csrf_token %}
{{form.geomcollection}}
<p><input type="submit" value="Submit"></p>

On Sat, Jun 18, 2011 at 7:21 PM, brutasse <
[email protected]>wrote:

The image loads fine here... It seems that it's trying to initialize
the BaseMetacartaWidget, the example I gave you was for BaseOsmWidget.
Depending on the base widget you use, you'll need to extend a
different widget template: in some-widget.html, when you do:

{% extends "floppyforms/gis/openlayers.html" %}

this is for BaseMetacartaWidget, it's likely to throw errors if you
use BaseOsmWidget. Can you check that?

If you want OpenStreetMap instead of the basic Metacarta layer, you
need to {% extend "floppyforms/gis/osm.html" %}

Same for Google Maps, you have a base google map widget and a template
to extend, "floppyforms/gis/google.html".

On Sat, Jun 18, 2011 at 3:41 PM, KasperaskyMe
[email protected]
wrote:

I did those changes too . Even though the map loads , the points or
polygons
don't really appear . This is the error
Image corrupt or truncated:

http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=22.5,-33.75,33.75,-22.5&WIDTH=256&HEIGHT=256

On Sat, Jun 18, 2011 at 6:56 PM, brutasse <
[email protected]>wrote:

You need two separate template. One for the widget, where you put
this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }} {{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

{% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
{{ form.media }}

{% csrf_token %}

{{form.geomcollection}}

My views

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

     LName = form.cleaned_data['LayerName']
         LDes = form.cleaned_data['LayerDescription']
     a.Layer_name=LName
                 a.Layer_desc=LDes
     a.save()

         form1 = ReadOnlyForm(data={'geomcollection': val})

     return render_to_response('some-widget.html',

({'form':form1}))

The template just shows a text box and a delete features button . I
am
assuming the OpenLayers is not getting intialized . What can be the
error
?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <
[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse admin
is a
total handicap . So I have to use django floppy forms and its
Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget
the
apply
permissions on particular users :) . Thank you again . Phew .
Never
knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no
need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for that
to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets
say
he
has
created a geometry collection field of data . And he has saved
it
in
the
database . now he wants to view the data again , and see if he
got
it
right
. if he hasn't , he has to edit the data . How does he edit
the
data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data. I
usually
do it with a custom readonly widget and form (here I'm using
a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon =
forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent your
users
from drawing on the map. Then, in your view, instantiate a
form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon
}}
and
you're done! Make sure there's no way to re-submit the form
though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going
quite
well .
Had
a
small doubt . After I save the data using django floppy
forms
and
its
Madwidget.js . Can I use the same to view the data that I
just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:
#14 (comment)

from django-floppyforms.

 avatar commented on May 30, 2024

Hello
Thanks for all the set up . Atlast everything is working smoothly . Though
with a small limitation .

val=form.cleaned_data['geom_val']
a.geom_poly=GeometryCollection(val[0],val[1],val[2],srid=900913)

See , val here is not a dict . So I cant traverse it . The only way I can
assign it , is what I am guessing is the way I have described above . This
limits me severly , in a way , that I can only draw 3 points , or 1 point ,
and 1 line , or one triangle on the map . Nothing more than that . Nothing
less than that . Still trying to figure out how to traverse the whole val ,
and feed it to geom_poly .

Apart from , its working pretty damn smooth . Thanks again .

On Sun, Jun 19, 2011 at 11:22 AM, brutasse <
[email protected]>wrote:

The JS error is because the geometry collection is not successfully
parsed. Obviously this is blocking the rendering.

Intanciating the form with an initial dict and assigning the geometry
to the form is not the same, you need to do it the way I told you. If
it's throwing an error, it's probably that the feature you created is
not properly constructed. What error is it?

That's my last email for today, I'm going offline. You're doing things
by hand so it's hard to debug and you really need to understand what
you're doing. Try to fix the geos error, try to understand why the
MapWidget is unable to parse the geometry (use the source :)

On 19 Jun 2011, at 07:31, KasperaskyMe
[email protected]
wrote:

I did check the html source . Did all the changes as you had mentioned .
The
source just has the POINTS . It doesnt have lines or polygons .
Also the Mapwidget.js is throwing an error . if (features.constructor ==
Array) { . Feature is undefined . Do you think that might be the cause
for
not being able to show the dict ?

And , another doubt is this .
form = ReadOnlyForm(initial={"
geomcollection": a.geom_poly})
I initialized the data like this . If I leave it at that , it gives me
GEOS
error .
But if I do this after that ,
form=form1.geomcollection = a.geom_poly
It doesn't . Doesnt the initialization itself do the same as the above
line
?

On Sun, Jun 19, 2011 at 10:20 AM, brutasse <
[email protected]>wrote:

First, it looks like you're mixing tabs and spaces for indentation.
Maybe it's just the email but if this is the case, fix your
indentation and your editor.

Given that there's no error thrown by python, it's likely to be
something else. I see that you're constructing a geometry by hand and
you're using google maps. Is your initial form using google maps too?

Check the generated HTML source. You should see a textarea element,
does it contain any data?

Anyway, there are two things to change:

  • when you create a GeometryCollection, give it an "srid" argument: if
    the data comes from a google map, do GeometryCollection(val[0],
    val[1], val[2], srid=900913). If you're using the Metacarta widget,
    use srid=4326. If it's OpenStreetMap, use 900913.
  • when you create the form, pass it a "initial" dictionnary. Assigning
    the field directly will never work:

form = ReadOnlyForm(initial={"geomcollection": a.geom_poly})

Once you've done this, check again what's in the textarea in the
generated HTML. You should see something like "GEOMETRYCOLLECTION(
....)".

You don't need to do anything in JavaScript, the layer will load on its
own.

On 19 Jun 2011, at 04:24, KasperaskyMe
[email protected]
wrote:

OpenLayers is loading fine . Its not getting truncated , but there in
loading of the data . Don't you think I need to save the data or
something
on the layer . Do an addlayer or something to get the data on the layer
?

My forms.py
class

GeometryCollectionWidget(forms.gis.GeometryCollectionWidget,forms.gis.BaseGMapWidget):

pass
class GeoForm(forms.Form):
AddLayer = forms.gis.GeometryCollectionField()
LayerName = forms.CharField()
LayerDescription = forms.CharField()

class ReadOnlyWidget(forms.gis.GeometryCollectionWidget,
forms.gis.BaseGMapWidget):
template_name = 'widget.html'

class ReadOnlyForm(forms.Form):
geomcollection =
forms.gis.GeometryCollectionField(widget=ReadOnlyWidget)

My views.py

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

      LName = form.cleaned_data['LayerName']
          LDes = form.cleaned_data['LayerDescription']
      a.Layer_name=LName
                  a.Layer_desc=LDes
      a.save()

          form1 = ReadOnlyForm()
      form1.geomcollection = a.geom_poly

      return render_to_response('some-widget.html',

({'form':form1}))

And some-widget.html

{{ form.media }}

{% csrf_token %}
{{form.geomcollection}}
<p><input type="submit" value="Submit"></p>

On Sat, Jun 18, 2011 at 7:21 PM, brutasse <
[email protected]>wrote:

The image loads fine here... It seems that it's trying to initialize
the BaseMetacartaWidget, the example I gave you was for BaseOsmWidget.
Depending on the base widget you use, you'll need to extend a
different widget template: in some-widget.html, when you do:

{% extends "floppyforms/gis/openlayers.html" %}

this is for BaseMetacartaWidget, it's likely to throw errors if you
use BaseOsmWidget. Can you check that?

If you want OpenStreetMap instead of the basic Metacarta layer, you
need to {% extend "floppyforms/gis/osm.html" %}

Same for Google Maps, you have a base google map widget and a template
to extend, "floppyforms/gis/google.html".

On Sat, Jun 18, 2011 at 3:41 PM, KasperaskyMe
[email protected]
wrote:

I did those changes too . Even though the map loads , the points or
polygons
don't really appear . This is the error
Image corrupt or truncated:

http://labs.metacarta.com/wms/vmap0?LAYERS=basic&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fjpeg&SRS=EPSG%3A4326&BBOX=22.5,-33.75,33.75,-22.5&WIDTH=256&HEIGHT=256

On Sat, Jun 18, 2011 at 6:56 PM, brutasse <
[email protected]>wrote:

You need two separate template. One for the widget, where you put
this:

{% extends "floppyforms/gis/openlayers.html" %}
{% block options %}{{ block.super }}
options['modifiable'] = true;{% endblock %}

Don't put anything else here. On your widget definition, point the
'template_name' attribute to this template (that'd be
'some-widget.html' template from my example above)

On the view, point to another template that does {{ form.media }}
{{
form.geomcollection }}

The first template is here to alter the functionality of the widget,
the second is the one used in your view, when you do
render_to_response.

On Sat, Jun 18, 2011 at 3:05 PM, KasperaskyMe
[email protected]
wrote:

This is what I did .

My template

{% extends "floppyforms/gis/openlayers.html" %}

{% block options %}{{ block.super }}
options['modifiable'] = true;

{% endblock %}
{{ form.media }}

{% csrf_token %}

{{form.geomcollection}}

My views

if request.method == 'POST':
form = GeoForm(request.POST)
if form.is_valid():
data = form.cleaned_data
val=form.cleaned_data['AddLayer']
val1=val[0]
val2=val[2]
val3=val[3]
a=Open_Layers()
a.geom_poly=GeometryCollection(val[0],val[1],val[3])

     LName = form.cleaned_data['LayerName']
         LDes = form.cleaned_data['LayerDescription']
     a.Layer_name=LName
                 a.Layer_desc=LDes
     a.save()

         form1 = ReadOnlyForm(data={'geomcollection': val})

     return render_to_response('some-widget.html',

({'form':form1}))

The template just shows a text box and a delete features button . I
am
assuming the OpenLayers is not getting intialized . What can be the
error
?

On Sat, Jun 18, 2011 at 5:39 PM, Satyajit Sarangi <
[email protected]

wrote:

Oh yeah . But lot of changes have to be done . The databrowse
admin
is a
total handicap . So I have to use django floppy forms and its
Mapwidget.js
to view the shapefile data . I hope that works

On Sat, Jun 18, 2011 at 5:38 PM, brutasse <
[email protected]>wrote:

Heh :) Really glad you like it!

On Sat, Jun 18, 2011 at 2:05 PM, KasperaskyMe
[email protected]
wrote:

Oh this solves a lot of purpose . i can use the read only widget
the
apply
permissions on particular users :) . Thank you again . Phew .
Never
knew
floppyforms can be this awesome

On Sat, Jun 18, 2011 at 5:34 PM, brutasse <
[email protected]>wrote:

Exactly, I thought you wanted to just display the data. Then no
need
for a readonly widget, create a form and pass it some data.

When I wrote ReadOnlyForm(data={....}), I meant
ReadOnlyForm(inital={the same dict}). Data is for validation :)

On Sat, Jun 18, 2011 at 2:00 PM, KasperaskyMe
[email protected]
wrote:

I am assuming I have to keep options[modfiable] = True for
that
to
happen?

On Sat, Jun 18, 2011 at 5:28 PM, Satyajit Sarangi <
[email protected]

wrote:

But what if the person wants to edit the data ? As in , lets
say
he
has
created a geometry collection field of data . And he has
saved
it
in
the
database . now he wants to view the data again , and see if
he
got
it
right
. if he hasn't , he has to edit the data . How does he edit
the
data
?

On Sat, Jun 18, 2011 at 5:24 PM, brutasse <
[email protected]>wrote:

Sure, you can use the MapWidget just to visualize the data.
I
usually
do it with a custom readonly widget and form (here I'm using
a
MultiPolygon but just change it to GeometryCollection):

import floppyforms as forms

class ReadOnlyWidget(forms.gis.MultiPolygonWidget,
forms.gis.BaseOsmWidget):
template_name = 'some-widget.html'

class ReadOnlyForm(forms.Form):
polygon =
forms.gis.MutliPolygonField(widget=ReadOnlyWidget)

Then in 'some-widget.html':

{% extends "floppyforms/gis/osm.js" %}

{% block options %}{{ block.super }}
options['modifiable'] = false;
{% endblock %}

The 'modifiable' option, when set to false, will prevent
your
users
from drawing on the map. Then, in your view, instantiate a
form
that
has this readonly widget:

form = ReadOnlyForm(data={'polygon':
what_you_got_in_the_previous_form})

In the template, output {{ form.media }} and {{ form.polygon
}}
and
you're done! Make sure there's no way to re-submit the form
though
:)

On Sat, Jun 18, 2011 at 1:25 PM, KasperaskyMe
[email protected]
wrote:

Hey there . The project I have been working on is going
quite
well .
Had
a
small doubt . After I save the data using django floppy
forms
and
its
Madwidget.js . Can I use the same to view the data that I
just
saved
?
As in
, view the GeometryCollection data that I just saved on an
openlayers
map ?
If yes , then how ?

On Wed, Jun 15, 2011 at 11:48 PM, brutasse <
[email protected]>wrote:

Totally, let me know when it's up :)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

Reply to this email directly or view it on GitHub:

#14 (comment)

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

Hi,

I'm glad it's working now. I don't understand the issue you're having,
do you mean that you want a geometry collection containing all the
elements of 'val'?

If so, you can create it like this:

a.geom_poly = GeometryCollection(*val, srid=900913)

This way, a geometry will be created with everything in it, whether
you have 1 or 10 or more items in val.

On Mon, Jun 20, 2011 at 11:34 AM, KasperaskyMe
[email protected]
wrote:

Hello
Thanks for all the set up . Atlast everything is working smoothly . Though
with a small limitation .

val=form.cleaned_data['geom_val']
a.geom_poly=GeometryCollection(val[0],val[1],val[2],srid=900913)

See , val here is not a dict . So I cant traverse it . The only way I can
assign it , is what I am guessing is the way I have described above . This
limits me severly , in a way , that I can only draw 3 points , or 1 point ,
and 1 line , or one triangle on the map . Nothing more than that . Nothing
less than that . Still trying to figure out how to traverse the whole val ,
and feed it to geom_poly .

Apart from , its working pretty damn smooth . Thanks again .

from django-floppyforms.

 avatar commented on May 30, 2024

Thanks to you my project is breathing now . Doing the final part , that is
mapping the shape files uploaded on an OSM map .

This is my forms.py

class ReadOnlyWidget(forms.gis.GeometryCollectionWidget,
forms.gis.BaseOsmWidget):
template_name = 'widgetosm.html'

class ReadOnlyForm(forms.Form):

geomcollection = forms.gis.GeometryCollectionField(widget=ReadOnlyWidget)

This is my views.py

def map_display(request):
a ="Parking"
lcount = Parking.objects.get(pk=2)

 form1 = ReadOnlyForm(initial={"geomcollection": lcount.geom})

 form1.geomcollection = lcount.geom
 return render_to_response('mapsdisplay.html', {'form':form1})

Shouldn' this be enough to view the data from the database model Parking's
first object .

I just get the osmmap . and nothing marked on it

Thanks
Satyajit
On Mon, Jun 20, 2011 at 6:19 PM, brutasse <
[email protected]>wrote:

Hi,

I'm glad it's working now. I don't understand the issue you're having,
do you mean that you want a geometry collection containing all the
elements of 'val'?

If so, you can create it like this:

a.geom_poly = GeometryCollection(*val, srid=900913)

This way, a geometry will be created with everything in it, whether
you have 1 or 10 or more items in val.

On Mon, Jun 20, 2011 at 11:34 AM, KasperaskyMe
[email protected]
wrote:

Hello
Thanks for all the set up . Atlast everything is working smoothly .
Though
with a small limitation .

val=form.cleaned_data['geom_val']
a.geom_poly=GeometryCollection(val[0],val[1],val[2],srid=900913)

See , val here is not a dict . So I cant traverse it . The only way I can
assign it , is what I am guessing is the way I have described above .
This
limits me severly , in a way , that I can only draw 3 points , or 1 point
,
and 1 line , or one triangle on the map . Nothing more than that .
Nothing
less than that . Still trying to figure out how to traverse the whole val
,
and feed it to geom_poly .

Apart from , its working pretty damn smooth . Thanks again .

Reply to this email directly or view it on GitHub:

#14 (comment)

Satyajit Sarangi

from django-floppyforms.

brutasse avatar brutasse commented on May 30, 2024

You don't need this line:

form1.geomcollection = lcount.geom

Next, I would bet on some projection issue. Do you have anything in the <textarea> on the rendered page? What shapefiles did you load and what projection are your models in?

from django-floppyforms.

 avatar commented on May 30, 2024

I have nothing in the rendered page apart from this

{{ form.media }} {% csrf_token %} {{ form.geomcollection }}

Add permission to the layer

</form>

I am not even trying out for shapefiles . Just doing it for the OSM maps I
have saved .

The exact same thing works in the app that allows me to make the OSM maps .
Lets say when I am done marking the OSM maps and click on the submit button
, the rendered template displays all the places that I have marked in a new
page .

I am trying the same thing here in a different map . I have imported all the
required models , maps and views .

On Wed, Jun 22, 2011 at 9:28 PM, brutasse <
[email protected]>wrote:

You don't need this line:

form1.geomcollection = lcount.geom

Next, I would bet on some projection issue. Do you have anything in the

<textarea> on the rendered page? What shapefiles did you load and what projection are your models in? ## Reply to this email directly or view it on GitHub: https://github.com//issues/14#issuecomment-1419015

Satyajit Sarangi

from django-floppyforms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.