SlideShare a Scribd company logo
1 of 35
Download to read offline
MapyHazardu.cz
Michal Valoušek / GDD 2011 Praha / 18.října 2011
Michal Valoušek

Vývojář webových aplikací / Django
@msgre / msgre.tumblr.com
Scuk.cz / EnergoMonitor.cz
Brnění o.s.
google.maps.Marker
       špendlíky heren
    google.maps.Polygon
vykreslení budov a jejich okolí
google.maps.event.addListener
   zavěšení na myší události
 google.maps.StyledMapType
      přebarvení mapy
Výpočet okolí budovy

>>> from django.contrib.gis.geos import Polygon

>>> building = Polygon([(10,10), (20,10), (20,20), (10,20), (10,10)])
>>> zone = building.buffer(50)
>>> print zone.coords

(((-90.0, 10.0),
  (-90.0, 20.0),
  (-88.07852804032305, 39.509032201612854),
  (-82.38795325112868, 58.26834323650898),
  ...
  (-88.07852804032294, -9.509032201613383),
  (-90.0, 10.0)),)
Výpočet konfliktu

>>> from django.contrib.gis.geos import Polygon, Point

>>> zone = Polygon([(10,10), (20,10), (20,20), (10,20), (10,10)])

>>> point1 = Point(0, 0)
>>> print zone.contains(point1)
False

>>> point2 = Point(15, 15)
>>> print zone.contains(point2)
True
http://www.exploreseakayaking.com/navigation.htm
http://maps.unomaha.edu/Peterson/gis/notes/MapProjCoord.html
Spatial Reference
            System Identity
                 (SRID)
>>> # WGS-84
>>> # souradnice se zadavaji jako dvojice (lon, lat)

>>> building = Polygon([(17.975283,   49.465755),
                        (17.975033,   49.465729),
                        (17.974962,   49.465992),
                        (17.975212,   49.466019),
                        (17.975283,   49.465755)], srid=4326)

>>> point = Point(17.9748452, 49.4695582, srid=4326)
WGS84
buffer(100)
Okolí & Křovák rulez!
>>> from django.contrib.gis.geos import Polygon
>>> from django.contrib.gis.gdal import CoordTransform, SpatialReference

>>> ct1 = CoordTransform(SpatialReference('WGS84'),
                         SpatialReference(102065))
>>> ct2 = CoordTransform(SpatialReference(102065),
                         SpatialReference('WGS84'))

>>> building = Polygon([(17.968216,49.469791),
                        ...,
                        (17.968216,49.469791)], srid=4326)

>>> building.transform(ct1)
>>> zone = building.buffer(100)   # 100 jakoze 100 m? ANO PROSÍM!
>>> zone.transform(ct2)
Vypočítat 100 m okolí budov

 Vypočítat konflikty heren
      a okolí budov

    Získat pozice heren

   Získat seznam budov
MapyHazardu.cz
maps.google.com
maps.google.com
maps.google.com
maps.google.com
mapyhazardu.cz/pridat/
Keyhole Markup Language (KML)
     <?xml version="1.0" encoding="UTF-8"?>
     <kml xmlns="http://earth.google.com/kml/2.2">
     <Document>
       <Placemark>
         <name>Škola pro sluchově postižené</name>
         <Polygon>
            <outerBoundaryIs>
              <LinearRing>
                <tessellate>1</tessellate>
                <coordinates>
                  17.975283,49.465755,0.000000
                  ...
                  17.975212,49.466019,0.000000
                  17.975283,49.465755,0.000000
                </coordinates>
              </LinearRing>
            </outerBoundaryIs>
         </Polygon>
       </Placemark>
     </Document>
     </kml>
Nová výzva
Seznam heren povolených MF
Import tabulky do Google Docs
Import tabulky do Google Docs

Doplnění přesných “GPS” pozic heren
Google Geocoding API
https://github.com/simonw/geocoders
gdata.spreadsheet.service.SpreadsheetsService
        knihovna “gdata-python-client”

>>> import gdata.spreadsheet.service

>>> client = gdata.spreadsheet.service.SpreadsheetsService()
>>> client.ClientLogin(GDOCS_USERNAME, GDOCS_PASSWORD)
>>> feed = client.GetListFeed(DOCUMENT_ID) # parametr “key” z URL

>>> for row_idx, entry in enumerate(feed.entry):
...     q = [entry.custom['ulice'].text, entry.custom['obec'].text]
...     gps = geocode(','.join(q))[1] # viz https://github.com/simonw/geocoders
...     gps = ','.join([str(i) for i in gps])
...     client.UpdateCell(row_idx + 2, 6, gps, DOCUMENT_ID)
Import tabulky do Google Docs

Doplnění přesných “GPS” pozic heren

Export dat z tabulky do KML po obcích
Import KML do maps.google.com
Import tabulky do Google Docs

Doplnění přesných “GPS” pozic heren

Export dat z tabulky do KML po obcích

       Získat data o budovách

 Import do aplikace mapyhazardu.cz
Import tabulky do Google Docs

Doplnění přesných “GPS” pozic heren

Export dat z tabulky do KML po obcích

       Získat data o budovách

 Import do aplikace mapyhazardu.cz
http://www.mapyhazardu.cz/gdd11/

 https://github.com/msgre/hazard

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

MapyHazardu.cz

  • 1. MapyHazardu.cz Michal Valoušek / GDD 2011 Praha / 18.října 2011
  • 2. Michal Valoušek Vývojář webových aplikací / Django @msgre / msgre.tumblr.com Scuk.cz / EnergoMonitor.cz
  • 3.
  • 5.
  • 6. google.maps.Marker špendlíky heren google.maps.Polygon vykreslení budov a jejich okolí google.maps.event.addListener zavěšení na myší události google.maps.StyledMapType přebarvení mapy
  • 7.
  • 8. Výpočet okolí budovy >>> from django.contrib.gis.geos import Polygon >>> building = Polygon([(10,10), (20,10), (20,20), (10,20), (10,10)]) >>> zone = building.buffer(50) >>> print zone.coords (((-90.0, 10.0), (-90.0, 20.0), (-88.07852804032305, 39.509032201612854), (-82.38795325112868, 58.26834323650898), ... (-88.07852804032294, -9.509032201613383), (-90.0, 10.0)),)
  • 9. Výpočet konfliktu >>> from django.contrib.gis.geos import Polygon, Point >>> zone = Polygon([(10,10), (20,10), (20,20), (10,20), (10,10)]) >>> point1 = Point(0, 0) >>> print zone.contains(point1) False >>> point2 = Point(15, 15) >>> print zone.contains(point2) True
  • 12. Spatial Reference System Identity (SRID) >>> # WGS-84 >>> # souradnice se zadavaji jako dvojice (lon, lat) >>> building = Polygon([(17.975283, 49.465755), (17.975033, 49.465729), (17.974962, 49.465992), (17.975212, 49.466019), (17.975283, 49.465755)], srid=4326) >>> point = Point(17.9748452, 49.4695582, srid=4326)
  • 14. Okolí & Křovák rulez! >>> from django.contrib.gis.geos import Polygon >>> from django.contrib.gis.gdal import CoordTransform, SpatialReference >>> ct1 = CoordTransform(SpatialReference('WGS84'), SpatialReference(102065)) >>> ct2 = CoordTransform(SpatialReference(102065), SpatialReference('WGS84')) >>> building = Polygon([(17.968216,49.469791), ..., (17.968216,49.469791)], srid=4326) >>> building.transform(ct1) >>> zone = building.buffer(100) # 100 jakoze 100 m? ANO PROSÍM! >>> zone.transform(ct2)
  • 15.
  • 16. Vypočítat 100 m okolí budov Vypočítat konflikty heren a okolí budov Získat pozice heren Získat seznam budov
  • 17.
  • 24. Keyhole Markup Language (KML) <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2"> <Document> <Placemark> <name>Škola pro sluchově postižené</name> <Polygon> <outerBoundaryIs> <LinearRing> <tessellate>1</tessellate> <coordinates> 17.975283,49.465755,0.000000 ... 17.975212,49.466019,0.000000 17.975283,49.465755,0.000000 </coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Document> </kml>
  • 27. Import tabulky do Google Docs
  • 28. Import tabulky do Google Docs Doplnění přesných “GPS” pozic heren
  • 30. gdata.spreadsheet.service.SpreadsheetsService knihovna “gdata-python-client” >>> import gdata.spreadsheet.service >>> client = gdata.spreadsheet.service.SpreadsheetsService() >>> client.ClientLogin(GDOCS_USERNAME, GDOCS_PASSWORD) >>> feed = client.GetListFeed(DOCUMENT_ID) # parametr “key” z URL >>> for row_idx, entry in enumerate(feed.entry): ... q = [entry.custom['ulice'].text, entry.custom['obec'].text] ... gps = geocode(','.join(q))[1] # viz https://github.com/simonw/geocoders ... gps = ','.join([str(i) for i in gps]) ... client.UpdateCell(row_idx + 2, 6, gps, DOCUMENT_ID)
  • 31. Import tabulky do Google Docs Doplnění přesných “GPS” pozic heren Export dat z tabulky do KML po obcích
  • 32. Import KML do maps.google.com
  • 33. Import tabulky do Google Docs Doplnění přesných “GPS” pozic heren Export dat z tabulky do KML po obcích Získat data o budovách Import do aplikace mapyhazardu.cz
  • 34. Import tabulky do Google Docs Doplnění přesných “GPS” pozic heren Export dat z tabulky do KML po obcích Získat data o budovách Import do aplikace mapyhazardu.cz