ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Geo-referencing content types in Plone with
collective.geo




               Where is my
                  content?
Who am I?
I'm senior developer and project manager with Abstract since 2011

I have been working with Plone since 2007

During the last years I have gained experience with various Python web
development frameworks




                                                                                     Abstract
                                            Where is my content? ¡ª Giorgio Borelli
Web maps: when, why and how
1. Complex and specialized GIS application
2. Maps are the central part of the app
      Panoramio
       Foursquare
       Only-apartments

3. Geo-referenced CMS




                                                                                   Abstract
                                          Where is my content? ¡ª Giorgio Borelli
What is collective.geo
collective.geo is a package that allows to geo-reference contents and to
display them on a map

http://plone.org/products/collective.geo


In 2008 I faced two problems

    learning Plone 3 and the Zope component architecture
    put a lot of contents on a map




                                                                                     Abstract
                                            Where is my content? ¡ª Giorgio Borelli
What if c.geo was not there
Plone products                             Cons
  Products.Maps           1. speci?c for Archetypes
  Products.ATGoogleMaps   2. can only georeference points
  redturtle.maps.core     3. can only use Google Maps
  raptus.article.map      4. developed for a speci?c project




                                                                        Abstract
                               Where is my content? ¡ª Giorgio Borelli
collective.geo manifesto
  modular and easily extendable
  up to date and taking advantage of ZCA
  not related to a speci?c map service




                                                                                    Abstract
                                           Where is my content? ¡ª Giorgio Borelli
Use cases
Use the location ?eld
ENEA
We can use the location ?eld
of a content-type to
geo-locate the of?ces of a
company

    Archetypes
    collective.geo

http://www.enea.it



                                                                        Abstract
                               Where is my content? ¡ª Giorgio Borelli
Dexterity content types TTW
Tropical Data Hub
We can assign collective.geo
Maps behaviour to a
Dexterity content-type in
order to make it
geo-referenceable

    Dexterity
    collective.geo.behaviour

http://tropicaldatahub.org/


                                                                        Abstract
                               Where is my content? ¡ª Giorgio Borelli
Not only points
IW:LEARN
c.geo allows to geo-reference
content with different shapes

    Points
    Lines
    Polygons

http://iwlearn.net/




                                                                         Abstract
                                Where is my content? ¡ª Giorgio Borelli
Flexitopic
We can aggregate
geo-referenced contents with
a Plone collection and, with
?exitopic, we can show the
results on a table and
paginate them

    collective.?exitopic
    c.geo.?exitopic




                                                                        Abstract
                               Where is my content? ¡ª Giorgio Borelli
More customizations
AORIF
The modular structure of
collective.geo allows us to
customize it in a simple way

On saving a content we can
geolocate its address and show
it on a map. The user doesn't
need to know the coordinates
neither to use a complex UI.




                                                                          Abstract
                                 Where is my content? ¡ª Giorgio Borelli
Backend/frontend
We can use a different javascript
map services to display contents.

    Google maps
    Polymaps http://polymaps.org/
    Lea?et
    http://lea?et.cloudmade.com

    Kartograph
    http://kartograph.org

http://ferraraterraeacqua.it/




                                                                             Abstract
                                    Where is my content? ¡ª Giorgio Borelli
Plone.it - users' map
We can also view the portal
users in a speci?c map

With a portlet we can include the
map in a different context such
as a landing page.

    collective.geo.usersmap

http://plone.it/partecipa




                                                                             Abstract
                                    Where is my content? ¡ª Giorgio Borelli
Looking for my content
Inside Plone              when an object is geo-referenced an
                          event is ?red by
   collective.geo.index   collective.geo.geographer

External catalogs              <subscriber
                                 handler=".MySubscriber"
   SOLR                          for="IObjectGeoreferencedEvent"
                               />
      collective.solr


   PostGIS




                                                                          Abstract
                                 Where is my content? ¡ª Giorgio Borelli
collective.geo under
      the hood
The core of collective.geo
Dependencies                     Installation
     Shapely                         [buildout]
                                     extends = http://dist.plone.org/release
     libgeos_c                       /4.2.1/versions.cfg

     geopy                           eggs =
                                       collective.geo.bundle
     BeautifulSoup                     BeautifulSoup
                                     ...




Note: Shapely dependency will be removed in the next release




                                                                                           Abstract
                                                  Where is my content? ¡ª Giorgio Borelli
collective.geo structure




                                                              Abstract
                     Where is my content? ¡ª Giorgio Borelli
collective.geo.openlayers
Includes the javascript library Openlayers in Plone and some other
javascripts that are useful for managing maps in collective.geo

  layer = new OpenLayers.Layer.Google(
    'Google maps',
    {
      'sphericalMercator':true,
      numZoomLevels:20
    }
  )




                                                                                     Abstract
                                            Where is my content? ¡ª Giorgio Borelli
collective.geo.geographer
    based on zgeo.geographer and      >>> class Placemark(object):
                                      ...     implements(
    zgeo.plone.geographer             ...       IGeoreferenceable,
                                      ...       IAttributeAnnotatable
    provides the basic mechanism to   ...     )
    enter geographic data into
                                      >>> placemark = Placemark()
    georeferenceable contents
                                      >>> geo = IGeoreferenced(placemark)
                                      >>> geo.setGeoInterface('Point',
any object can be georeferenced       ...               (-105.08, 40.59))




                                                                                  Abstract
                                         Where is my content? ¡ª Giorgio Borelli
collective.geo.settings
store default settings for collective.geo

    map center
    zoom level
    which layers have to be shown on the map
    which contents can be georeferenced
    default styles for all features




                                                                                     Abstract
                                            Where is my content? ¡ª Giorgio Borelli
collective.geo.mapwidget
  manages the mechanism that handles Openlayers maps in Plone
  each map widget is a Zope component which contains a series of
  layers
  all the maps in collective.geo are composed by one or more map
  layers and each layer returns a javascript snippet by a page template
  which contains all information about the layer itself




                                                                                   Abstract
                                          Where is my content? ¡ª Giorgio Borelli
collective.geo.mapwidget
 >>> from collective.geo.mapwidget import maplayer
 >>> class BingStretMapLayer(maplayer.MapLayer):
 ...     name = u"bing_map"
 ...     Title = _(u'Bing Streets')
 ...     type = 'bing'
 ...     jsfactory = """
 ...       function() {
 ...         return new OpenLayers.Layer.VirtualEarth('%s',
 ...           {'type': VEMapStyle.Shaded,
 ...            'sphericalMercator': true});
 ...       }""" % Title




 <metal:layer
     use-macro="context/@@collectivegeo-macros/map-widget" />
collective.geo.contentlocations
user interface for georeferencing Archetypes content types


    data can be inserted in WKT
    format
    geocoding with geopy
    it is possible to set
    customized styles




                                                                                          Abstract
                                                 Where is my content? ¡ª Giorgio Borelli
collective.geo.kml
registers a kml view on the georeferenced objects and on folderish
contents such as Folders and Collections.

the KML ?le can be used on external services like Google Earth/Maps




                                                                                     Abstract
                                            Where is my content? ¡ª Giorgio Borelli
Dexterity
collective.z3cform.mapwidget
     it's a speci?c widget for z3c.form that allows to manage the
     geographic data in an easy way

collective.geo.behaviour
     it's a Dexterity behaviour that allows to georeference contents and
     uses the annotations mechanism of collective.geo.geographer for
     registering data




                                                                                      Abstract
                                             Where is my content? ¡ª Giorgio Borelli
More extensions
collective.geo.mapcontent




                                                             Abstract
                    Where is my content? ¡ª Giorgio Borelli
collective.geo.?le
it provides a view for KML, KMZ (Keyhole Markup Language) and GPX
(GPS eXchange Format) ?les.

The view renders the ?le in a openlayers Map using the collective.geo
library.




                                                                                     Abstract
                                            Where is my content? ¡ª Giorgio Borelli
Conclusion
 7 packages on the core (two more for Dexterity soon)
 9 addons packages
 translated in 9 languages
 Coactivate http://www.coactivate.org/projects/collectivegeo
 Readthedocs http://collectivegeo.readthedocs.org




                                                                                  Abstract
                                         Where is my content? ¡ª Giorgio Borelli
Contributors
 Sean Gillies                 Christian Ledermann - nan
 Silvio Tomatis - silviot     David Beitey - davidjb
 Gerhard Weis - gweis         Maurizio Delmonte - miziodel
 David Breitkreutz - rockdj   Alice Narduzzo
 Makina corpus                Enrico Barra




                                                                         Abstract
                                Where is my content? ¡ª Giorgio Borelli

More Related Content

Where is my content?

  • 1. Geo-referencing content types in Plone with collective.geo Where is my content?
  • 2. Who am I? I'm senior developer and project manager with Abstract since 2011 I have been working with Plone since 2007 During the last years I have gained experience with various Python web development frameworks Abstract Where is my content? ¡ª Giorgio Borelli
  • 3. Web maps: when, why and how 1. Complex and specialized GIS application 2. Maps are the central part of the app Panoramio Foursquare Only-apartments 3. Geo-referenced CMS Abstract Where is my content? ¡ª Giorgio Borelli
  • 4. What is collective.geo collective.geo is a package that allows to geo-reference contents and to display them on a map http://plone.org/products/collective.geo In 2008 I faced two problems learning Plone 3 and the Zope component architecture put a lot of contents on a map Abstract Where is my content? ¡ª Giorgio Borelli
  • 5. What if c.geo was not there Plone products Cons Products.Maps 1. speci?c for Archetypes Products.ATGoogleMaps 2. can only georeference points redturtle.maps.core 3. can only use Google Maps raptus.article.map 4. developed for a speci?c project Abstract Where is my content? ¡ª Giorgio Borelli
  • 6. collective.geo manifesto modular and easily extendable up to date and taking advantage of ZCA not related to a speci?c map service Abstract Where is my content? ¡ª Giorgio Borelli
  • 8. Use the location ?eld ENEA We can use the location ?eld of a content-type to geo-locate the of?ces of a company Archetypes collective.geo http://www.enea.it Abstract Where is my content? ¡ª Giorgio Borelli
  • 9. Dexterity content types TTW Tropical Data Hub We can assign collective.geo Maps behaviour to a Dexterity content-type in order to make it geo-referenceable Dexterity collective.geo.behaviour http://tropicaldatahub.org/ Abstract Where is my content? ¡ª Giorgio Borelli
  • 10. Not only points IW:LEARN c.geo allows to geo-reference content with different shapes Points Lines Polygons http://iwlearn.net/ Abstract Where is my content? ¡ª Giorgio Borelli
  • 11. Flexitopic We can aggregate geo-referenced contents with a Plone collection and, with ?exitopic, we can show the results on a table and paginate them collective.?exitopic c.geo.?exitopic Abstract Where is my content? ¡ª Giorgio Borelli
  • 12. More customizations AORIF The modular structure of collective.geo allows us to customize it in a simple way On saving a content we can geolocate its address and show it on a map. The user doesn't need to know the coordinates neither to use a complex UI. Abstract Where is my content? ¡ª Giorgio Borelli
  • 13. Backend/frontend We can use a different javascript map services to display contents. Google maps Polymaps http://polymaps.org/ Lea?et http://lea?et.cloudmade.com Kartograph http://kartograph.org http://ferraraterraeacqua.it/ Abstract Where is my content? ¡ª Giorgio Borelli
  • 14. Plone.it - users' map We can also view the portal users in a speci?c map With a portlet we can include the map in a different context such as a landing page. collective.geo.usersmap http://plone.it/partecipa Abstract Where is my content? ¡ª Giorgio Borelli
  • 15. Looking for my content Inside Plone when an object is geo-referenced an event is ?red by collective.geo.index collective.geo.geographer External catalogs <subscriber handler=".MySubscriber" SOLR for="IObjectGeoreferencedEvent" /> collective.solr PostGIS Abstract Where is my content? ¡ª Giorgio Borelli
  • 17. The core of collective.geo Dependencies Installation Shapely [buildout] extends = http://dist.plone.org/release libgeos_c /4.2.1/versions.cfg geopy eggs = collective.geo.bundle BeautifulSoup BeautifulSoup ... Note: Shapely dependency will be removed in the next release Abstract Where is my content? ¡ª Giorgio Borelli
  • 18. collective.geo structure Abstract Where is my content? ¡ª Giorgio Borelli
  • 19. collective.geo.openlayers Includes the javascript library Openlayers in Plone and some other javascripts that are useful for managing maps in collective.geo layer = new OpenLayers.Layer.Google( 'Google maps', { 'sphericalMercator':true, numZoomLevels:20 } ) Abstract Where is my content? ¡ª Giorgio Borelli
  • 20. collective.geo.geographer based on zgeo.geographer and >>> class Placemark(object): ... implements( zgeo.plone.geographer ... IGeoreferenceable, ... IAttributeAnnotatable provides the basic mechanism to ... ) enter geographic data into >>> placemark = Placemark() georeferenceable contents >>> geo = IGeoreferenced(placemark) >>> geo.setGeoInterface('Point', any object can be georeferenced ... (-105.08, 40.59)) Abstract Where is my content? ¡ª Giorgio Borelli
  • 21. collective.geo.settings store default settings for collective.geo map center zoom level which layers have to be shown on the map which contents can be georeferenced default styles for all features Abstract Where is my content? ¡ª Giorgio Borelli
  • 22. collective.geo.mapwidget manages the mechanism that handles Openlayers maps in Plone each map widget is a Zope component which contains a series of layers all the maps in collective.geo are composed by one or more map layers and each layer returns a javascript snippet by a page template which contains all information about the layer itself Abstract Where is my content? ¡ª Giorgio Borelli
  • 23. collective.geo.mapwidget >>> from collective.geo.mapwidget import maplayer >>> class BingStretMapLayer(maplayer.MapLayer): ... name = u"bing_map" ... Title = _(u'Bing Streets') ... type = 'bing' ... jsfactory = """ ... function() { ... return new OpenLayers.Layer.VirtualEarth('%s', ... {'type': VEMapStyle.Shaded, ... 'sphericalMercator': true}); ... }""" % Title <metal:layer use-macro="context/@@collectivegeo-macros/map-widget" />
  • 24. collective.geo.contentlocations user interface for georeferencing Archetypes content types data can be inserted in WKT format geocoding with geopy it is possible to set customized styles Abstract Where is my content? ¡ª Giorgio Borelli
  • 25. collective.geo.kml registers a kml view on the georeferenced objects and on folderish contents such as Folders and Collections. the KML ?le can be used on external services like Google Earth/Maps Abstract Where is my content? ¡ª Giorgio Borelli
  • 26. Dexterity collective.z3cform.mapwidget it's a speci?c widget for z3c.form that allows to manage the geographic data in an easy way collective.geo.behaviour it's a Dexterity behaviour that allows to georeference contents and uses the annotations mechanism of collective.geo.geographer for registering data Abstract Where is my content? ¡ª Giorgio Borelli
  • 28. collective.geo.mapcontent Abstract Where is my content? ¡ª Giorgio Borelli
  • 29. collective.geo.?le it provides a view for KML, KMZ (Keyhole Markup Language) and GPX (GPS eXchange Format) ?les. The view renders the ?le in a openlayers Map using the collective.geo library. Abstract Where is my content? ¡ª Giorgio Borelli
  • 30. Conclusion 7 packages on the core (two more for Dexterity soon) 9 addons packages translated in 9 languages Coactivate http://www.coactivate.org/projects/collectivegeo Readthedocs http://collectivegeo.readthedocs.org Abstract Where is my content? ¡ª Giorgio Borelli
  • 31. Contributors Sean Gillies Christian Ledermann - nan Silvio Tomatis - silviot David Beitey - davidjb Gerhard Weis - gweis Maurizio Delmonte - miziodel David Breitkreutz - rockdj Alice Narduzzo Makina corpus Enrico Barra Abstract Where is my content? ¡ª Giorgio Borelli