SlideShare a Scribd company logo
1 of 25
PATCH MAPS
Who, What, When, Where, Why, How?
           Aubrey Holland
WHO?
•   Patch.com is a local news and information service

•   We have editorial staff in each of our 44 communities and are
    expanding to cover hundreds of communities across the country this
    year

•   Our goal is to be the equivalent of a local paper in each town, and we
    cover everything that goes on there, including everything from the
    school board meeting to restaurant reviews and obituaries

•    We also have a significant listings-gathering process that collects
    information on every business in town

•   In general, all of our data is connected to geographic information
WHAT?
WHERE?
• Patch   is in SoHo, NYC
WHEN?

• We started considering this project after seeing Paul Smith’s
 “Take Control of Your Maps” article on A List Apart in April,
 2008

• The
    project really took shape in August, 2009 and launched in
 November
WHY?

• Ourpainful design process left us with a custom page, and a
 map that looks just like everybody else’s

• Map   data at the highly local level still kinda sucks

• You   can’t integrate data directly into a Google (etc.) map
THE STACK
   Apache (mod_wsgi)


       TileCache


         Mapnik


PostGIS (with OSM planet)
APACHE CONFIG
In httpd.conf:
     LoadModule wsgi_module modules/mod_wsgi.so


In your sites-available/config:
    WSGIDaemonProcess patch processes=25 threads=1 display-
   name=%{GROUP}
    WSGIProcessGroup patch
    WSGIScriptAlias /tilecache
   /data/servers/patch_maps-fe-apache/wsgi/tilecache.wsgi



Now, you can restart the WSGI service simply by
               touching this file
TILECACHE WSGI CONFIG
This is the application that is executed with each request:
    #!/opt/bcs/python2.6
    #
    # In Apache2's config:
    # WSGIScriptAlias /tilecache /var/www/mapserver/tilecache/tilecache.wsgi
    #
    import os, sys
    tilecachepath = '/srv/data/servers/patch_maps-fe-apache/tilecache'
    sys.path.append(tilecachepath)

    from TileCache.Service import Service, wsgiHandler

    cfgfiles = (os.path.join(tilecachepath, 'tilecache.cfg'))

    theService = None
    def application(environ, start_response):
        global theService

       cfgs = cfgfiles
       if not theService:
           theService = Service.load(cfgs)
       return wsgiHandler(environ, start_response, theService)
TILECACHE CONFIG
[cache]
type=Disk
base=/data/servers/dr1nas-a-v1b/shared/common/map_tiles
expire=21600

[osm]
type=Mapnik
mapfile=/opt/bcs/packages/map_style-0.0.1/mapfile.xml
spherical_mercator=true
tms_type=google
metaTile=yes
metaSize=1,1
metaBuffer=256
levels=19
extension=png256
MAPNIK
• Mapnikrequires a mapfile telling it how to render tiles as
 requests come in

• Ourswas built using cascadenik, with help from Stamen
 Design, and we compiled the file to the mapfile format

• Thatstylesheet contains all of the queries to make against the
 database in order to render each layer, along with information
 on how to style them

• Cascadeniklets you write this in a CSS/HTML-like format,
 where the style is separated from the content
OPTIMIZING QUERIES
From this:
    (SELECT way, name FROM osm_polygon WHERE amenity IN ('school',
    'college', 'university', 'bus_station', 'ferry_terminal',
    'hospital', 'kindergarten', 'place_of_worship',
    'public_building', 'townhall') ORDER BY z_order ASC, way_area
    DESC) AS civic


To this:
    (SELECT way, name FROM osm_polygon_civic_areas_mv ORDER BY
    z_order ASC, way_area DESC) AS civic
BUILDING THE DATABASE

• Weuse the full planet.osm, though we’re only focused in
 North America at the moment

• The initial import was done by downloading the planet file
 and importing it using osm2pgsql. This took four days!!!

• We  have a replicated slave database, as well as a static copy
 that we back up to once per month
TILE_FLIP
           http://github.com/aub/tile_flip

•Uses the TileCache API to provide a simple
 interface for managing tiles
•Seeding
•Killing
•Finding
KILLING TILES
def __init__(self, tileCacheConfigFile):

def killForPoint(
    self,
    layerName,
    point,
    delta=(0.0, 0.0),
    levels=None,
    tilePadding=0):

def killForTmsPath(self, layerName, x, y, z):

def killToSize(self, maxMBs):

def killAll(self):

def killTile(self, tile):
SEEDING TILES
def __init__(self, tileCacheConfigFile, userId=-1, groupId=-1):

def seedForPoint(
    self,
    layerName,
    point,
    delta=(0.0, 0.0),
    levels=None,
    tilePadding=0,
    force=False):

def seedForTmsPath(self, layerName, x, y, z, force=False):

def seedForTile(self, tile, force=False):
FINDING TILES
def __init__(self, tileCacheConfigFile):

def findTiles(
    self,
    layerName,
    levels=None,
    bbox=None,
    tilePadding=0,
    block=None):

def isTmsPathCached(self, layerName, x, y, z):
BACKGROUND TASKS

• Apply    updates to the OSM data once per minute

• Expire   cached tiles that were affected by the data update

• Publication   updating and seeding

• Seeding   low zoom levels

• Trimming    the cache to a reasonable size
APPLYING MINUTELY
             UPDATES
  http://wiki.openstreetmap.org/wiki/Minutely_Mapnik
We have a python script that runs every minute via cron
 /opt/bcs/bin/osmosis -q --read-replication-interval
    workingDirectory=/srv/data/osm/osmosis/replication
    --write-xml-change /dev/stdout |
    /opt/bcs/bin/osm2pgsql --append --database=osm
    --username=polarmaps_rw --host=patchbe-d03.ihost.aol.com
    --port=5432 --merc --prefix=osm --slim
    --style /opt/bcs/packages/osm2pgsql-1.0.0/osm2pgsql.style
    --expire-tiles=18
    --expire-output=/srv/data/osm/expiration_lists/tmpvj1Glb
    - 2>> /srv/data/osm/log/osm2pgsql.log
APPLYING MINUTELY
              UPDATES
  osm2pgsql produces an expiration list that looks like:
                    18/42005/91478
                    18/42005/91479
                    18/42006/91478

 Our script then parses this file and adds each tile and its
  ancestors to a table in the database. A separate script
then crawls that table and uses tile_flip to expire the tiles
PUBLICATION UPDATING
            AND SEEDING
• We have a set of publications, and almost all of our tile
 requests are for areas around them

• The publications have a bounding box, and we have an API for
 getting the publication data along with it’s location information

• Anotherscript running via cron then uses tile_flip to
 automatically seed an area around each publication at all zoom
 levels
LOW ZOOM LEVEL SEEDING

• The   low zoom levels are the slowest to render

• So, wehave another script that walks levels 10-14 for the
 entire USA and pre-seeds those tiles using tile_flip
STATIC MAPS
               http://github.com/aub/static_maps/
• Once you have all of this set up, it’s amazingly simple to add
 other services, like a static map renderer

• Mapnik    has an excellent Python API you can use

• Setting
        up other services is as simple as writing a Python script
 and adding another WSGI service to Apache

• Our static map service has two endpoints, one for rendering a
 map centered around a set of points, and the second for
 returning a JSON response with the pixel positions of those
 points
PATCH IS HIRING!
QUESTIONS?
aubreyholland@gmail.com

@riotpolice

http://github.com/aub

http://www.patch.com

More Related Content

What's hot

Photon Session / Unite12 Conference
Photon Session / Unite12 ConferencePhoton Session / Unite12 Conference
Photon Session / Unite12 ConferenceChristof Wegmann
 
Important work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingualImportant work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingualAxel Faust
 
Building Repeatable Infrastructure using Terraform
Building Repeatable Infrastructure using TerraformBuilding Repeatable Infrastructure using Terraform
Building Repeatable Infrastructure using TerraformJeeva Chelladhurai
 
CI/CD with Kubernetes, Helm & Wercker (#madScalability)
CI/CD with Kubernetes, Helm & Wercker (#madScalability)CI/CD with Kubernetes, Helm & Wercker (#madScalability)
CI/CD with Kubernetes, Helm & Wercker (#madScalability)Diacode
 
vBrownBag @ VMworld - Apache CloudStack (ACS) & vSphere
vBrownBag @ VMworld - Apache CloudStack (ACS) & vSpherevBrownBag @ VMworld - Apache CloudStack (ACS) & vSphere
vBrownBag @ VMworld - Apache CloudStack (ACS) & vSphereAaron Delp
 
Beyond 1000 bosh Deployments
Beyond 1000 bosh DeploymentsBeyond 1000 bosh Deployments
Beyond 1000 bosh Deploymentsanynines GmbH
 
Intro to Clojure 4 Developers
Intro to Clojure 4 DevelopersIntro to Clojure 4 Developers
Intro to Clojure 4 DevelopersNola Stowe
 
Altitude SF 2017: Stories from TED
Altitude SF 2017: Stories from TEDAltitude SF 2017: Stories from TED
Altitude SF 2017: Stories from TEDFastly
 
What can-be-done-around-mesos
What can-be-done-around-mesosWhat can-be-done-around-mesos
What can-be-done-around-mesosZhou Weitao
 
Storage Is Not Virtualized Enough - part 1
Storage Is Not Virtualized Enough - part 1Storage Is Not Virtualized Enough - part 1
Storage Is Not Virtualized Enough - part 1Zhipeng Huang
 
NoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern SuccessNoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern SuccessArun Gupta
 
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Swapnil Dahiphale
 

What's hot (16)

Photon Session / Unite12 Conference
Photon Session / Unite12 ConferencePhoton Session / Unite12 Conference
Photon Session / Unite12 Conference
 
Important work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingualImportant work-arounds for making ASS multi-lingual
Important work-arounds for making ASS multi-lingual
 
Effective terraform
Effective terraformEffective terraform
Effective terraform
 
Building Repeatable Infrastructure using Terraform
Building Repeatable Infrastructure using TerraformBuilding Repeatable Infrastructure using Terraform
Building Repeatable Infrastructure using Terraform
 
CI/CD with Kubernetes, Helm & Wercker (#madScalability)
CI/CD with Kubernetes, Helm & Wercker (#madScalability)CI/CD with Kubernetes, Helm & Wercker (#madScalability)
CI/CD with Kubernetes, Helm & Wercker (#madScalability)
 
vBrownBag @ VMworld - Apache CloudStack (ACS) & vSphere
vBrownBag @ VMworld - Apache CloudStack (ACS) & vSpherevBrownBag @ VMworld - Apache CloudStack (ACS) & vSphere
vBrownBag @ VMworld - Apache CloudStack (ACS) & vSphere
 
Photon Load Test #1
Photon Load Test #1Photon Load Test #1
Photon Load Test #1
 
EC2 Container Service
EC2 Container ServiceEC2 Container Service
EC2 Container Service
 
Navigation in React Native
Navigation in React NativeNavigation in React Native
Navigation in React Native
 
Beyond 1000 bosh Deployments
Beyond 1000 bosh DeploymentsBeyond 1000 bosh Deployments
Beyond 1000 bosh Deployments
 
Intro to Clojure 4 Developers
Intro to Clojure 4 DevelopersIntro to Clojure 4 Developers
Intro to Clojure 4 Developers
 
Altitude SF 2017: Stories from TED
Altitude SF 2017: Stories from TEDAltitude SF 2017: Stories from TED
Altitude SF 2017: Stories from TED
 
What can-be-done-around-mesos
What can-be-done-around-mesosWhat can-be-done-around-mesos
What can-be-done-around-mesos
 
Storage Is Not Virtualized Enough - part 1
Storage Is Not Virtualized Enough - part 1Storage Is Not Virtualized Enough - part 1
Storage Is Not Virtualized Enough - part 1
 
NoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern SuccessNoSQL - Vital Open Source Ingredient for Modern Success
NoSQL - Vital Open Source Ingredient for Modern Success
 
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
 

Similar to Patch Maps

Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt versionrudy_stricklan
 
ScribeUI: La productivité avec MapServer
ScribeUI: La productivité avec MapServerScribeUI: La productivité avec MapServer
ScribeUI: La productivité avec MapServerVisionGEOMATIQUE2014
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceOSCON Byrum
 
Saving Money with Open Source GIS
Saving Money with Open Source GISSaving Money with Open Source GIS
Saving Money with Open Source GISbryanluman
 
Building Maps with Leaflet
Building Maps with LeafletBuilding Maps with Leaflet
Building Maps with LeafletAndrew Howard
 
Open Source Web Mapping Servers: Which horse for which course?
Open Source Web Mapping Servers: Which horse for which course?Open Source Web Mapping Servers: Which horse for which course?
Open Source Web Mapping Servers: Which horse for which course?antscott
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNATomas Cervenka
 
Integrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsIntegrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsCommand Prompt., Inc
 
Internet-enabled GIS Using Free and Open Source Tools
Internet-enabled GIS Using Free and Open Source ToolsInternet-enabled GIS Using Free and Open Source Tools
Internet-enabled GIS Using Free and Open Source ToolsJohn Reiser
 
Social Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDBSocial Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDBTakahiro Inoue
 
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_SummaryHiram Fleitas León
 
Spark shuffle introduction
Spark shuffle introductionSpark shuffle introduction
Spark shuffle introductioncolorant
 
True Reusable Code - DevSum2016
True Reusable Code - DevSum2016True Reusable Code - DevSum2016
True Reusable Code - DevSum2016Eduard Lazar
 
Putting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OS
Putting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OSPutting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OS
Putting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OSLightbend
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSuzquiano
 
Saltconf16 william-cannon b
Saltconf16 william-cannon bSaltconf16 william-cannon b
Saltconf16 william-cannon bWilliam Cannon
 

Similar to Patch Maps (20)

Web enabling your survey business ppt version
Web enabling your survey business ppt versionWeb enabling your survey business ppt version
Web enabling your survey business ppt version
 
ScribeUI: La productivité avec MapServer
ScribeUI: La productivité avec MapServerScribeUI: La productivité avec MapServer
ScribeUI: La productivité avec MapServer
 
TechBeats #2
TechBeats #2TechBeats #2
TechBeats #2
 
State of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open SourceState of the Art Web Mapping with Open Source
State of the Art Web Mapping with Open Source
 
Saving Money with Open Source GIS
Saving Money with Open Source GISSaving Money with Open Source GIS
Saving Money with Open Source GIS
 
Building Maps with Leaflet
Building Maps with LeafletBuilding Maps with Leaflet
Building Maps with Leaflet
 
Open Source Web Mapping Servers: Which horse for which course?
Open Source Web Mapping Servers: Which horse for which course?Open Source Web Mapping Servers: Which horse for which course?
Open Source Web Mapping Servers: Which horse for which course?
 
Implementing your own Google App Engine
Implementing your own Google App Engine Implementing your own Google App Engine
Implementing your own Google App Engine
 
Maps tek11
Maps tek11Maps tek11
Maps tek11
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
 
Integrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsIntegrating PostGIS in Web Applications
Integrating PostGIS in Web Applications
 
Internet-enabled GIS Using Free and Open Source Tools
Internet-enabled GIS Using Free and Open Source ToolsInternet-enabled GIS Using Free and Open Source Tools
Internet-enabled GIS Using Free and Open Source Tools
 
Social Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDBSocial Data and Log Analysis Using MongoDB
Social Data and Log Analysis Using MongoDB
 
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
 
Spark shuffle introduction
Spark shuffle introductionSpark shuffle introduction
Spark shuffle introduction
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
True Reusable Code - DevSum2016
True Reusable Code - DevSum2016True Reusable Code - DevSum2016
True Reusable Code - DevSum2016
 
Putting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OS
Putting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OSPutting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OS
Putting Kafka In Jail – Best Practices To Run Kafka On Kubernetes & DC/OS
 
Hazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMSHazelcast and MongoDB at Cloud CMS
Hazelcast and MongoDB at Cloud CMS
 
Saltconf16 william-cannon b
Saltconf16 william-cannon bSaltconf16 william-cannon b
Saltconf16 william-cannon b
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Patch Maps

  • 1. PATCH MAPS Who, What, When, Where, Why, How? Aubrey Holland
  • 2. WHO? • Patch.com is a local news and information service • We have editorial staff in each of our 44 communities and are expanding to cover hundreds of communities across the country this year • Our goal is to be the equivalent of a local paper in each town, and we cover everything that goes on there, including everything from the school board meeting to restaurant reviews and obituaries • We also have a significant listings-gathering process that collects information on every business in town • In general, all of our data is connected to geographic information
  • 4. WHERE? • Patch is in SoHo, NYC
  • 5. WHEN? • We started considering this project after seeing Paul Smith’s “Take Control of Your Maps” article on A List Apart in April, 2008 • The project really took shape in August, 2009 and launched in November
  • 6. WHY? • Ourpainful design process left us with a custom page, and a map that looks just like everybody else’s • Map data at the highly local level still kinda sucks • You can’t integrate data directly into a Google (etc.) map
  • 7. THE STACK Apache (mod_wsgi) TileCache Mapnik PostGIS (with OSM planet)
  • 8. APACHE CONFIG In httpd.conf: LoadModule wsgi_module modules/mod_wsgi.so In your sites-available/config:  WSGIDaemonProcess patch processes=25 threads=1 display- name=%{GROUP}  WSGIProcessGroup patch  WSGIScriptAlias /tilecache /data/servers/patch_maps-fe-apache/wsgi/tilecache.wsgi Now, you can restart the WSGI service simply by touching this file
  • 9. TILECACHE WSGI CONFIG This is the application that is executed with each request: #!/opt/bcs/python2.6 # # In Apache2's config: # WSGIScriptAlias /tilecache /var/www/mapserver/tilecache/tilecache.wsgi # import os, sys tilecachepath = '/srv/data/servers/patch_maps-fe-apache/tilecache' sys.path.append(tilecachepath) from TileCache.Service import Service, wsgiHandler cfgfiles = (os.path.join(tilecachepath, 'tilecache.cfg')) theService = None def application(environ, start_response): global theService cfgs = cfgfiles if not theService: theService = Service.load(cfgs) return wsgiHandler(environ, start_response, theService)
  • 11. MAPNIK • Mapnikrequires a mapfile telling it how to render tiles as requests come in • Ourswas built using cascadenik, with help from Stamen Design, and we compiled the file to the mapfile format • Thatstylesheet contains all of the queries to make against the database in order to render each layer, along with information on how to style them • Cascadeniklets you write this in a CSS/HTML-like format, where the style is separated from the content
  • 12. OPTIMIZING QUERIES From this: (SELECT way, name FROM osm_polygon WHERE amenity IN ('school', 'college', 'university', 'bus_station', 'ferry_terminal', 'hospital', 'kindergarten', 'place_of_worship', 'public_building', 'townhall') ORDER BY z_order ASC, way_area DESC) AS civic To this: (SELECT way, name FROM osm_polygon_civic_areas_mv ORDER BY z_order ASC, way_area DESC) AS civic
  • 13. BUILDING THE DATABASE • Weuse the full planet.osm, though we’re only focused in North America at the moment • The initial import was done by downloading the planet file and importing it using osm2pgsql. This took four days!!! • We have a replicated slave database, as well as a static copy that we back up to once per month
  • 14. TILE_FLIP http://github.com/aub/tile_flip •Uses the TileCache API to provide a simple interface for managing tiles •Seeding •Killing •Finding
  • 15. KILLING TILES def __init__(self, tileCacheConfigFile): def killForPoint( self, layerName, point, delta=(0.0, 0.0), levels=None, tilePadding=0): def killForTmsPath(self, layerName, x, y, z): def killToSize(self, maxMBs): def killAll(self): def killTile(self, tile):
  • 16. SEEDING TILES def __init__(self, tileCacheConfigFile, userId=-1, groupId=-1): def seedForPoint( self, layerName, point, delta=(0.0, 0.0), levels=None, tilePadding=0, force=False): def seedForTmsPath(self, layerName, x, y, z, force=False): def seedForTile(self, tile, force=False):
  • 17. FINDING TILES def __init__(self, tileCacheConfigFile): def findTiles( self, layerName, levels=None, bbox=None, tilePadding=0, block=None): def isTmsPathCached(self, layerName, x, y, z):
  • 18. BACKGROUND TASKS • Apply updates to the OSM data once per minute • Expire cached tiles that were affected by the data update • Publication updating and seeding • Seeding low zoom levels • Trimming the cache to a reasonable size
  • 19. APPLYING MINUTELY UPDATES http://wiki.openstreetmap.org/wiki/Minutely_Mapnik We have a python script that runs every minute via cron /opt/bcs/bin/osmosis -q --read-replication-interval workingDirectory=/srv/data/osm/osmosis/replication --write-xml-change /dev/stdout | /opt/bcs/bin/osm2pgsql --append --database=osm --username=polarmaps_rw --host=patchbe-d03.ihost.aol.com --port=5432 --merc --prefix=osm --slim --style /opt/bcs/packages/osm2pgsql-1.0.0/osm2pgsql.style --expire-tiles=18 --expire-output=/srv/data/osm/expiration_lists/tmpvj1Glb - 2>> /srv/data/osm/log/osm2pgsql.log
  • 20. APPLYING MINUTELY UPDATES osm2pgsql produces an expiration list that looks like: 18/42005/91478 18/42005/91479 18/42006/91478 Our script then parses this file and adds each tile and its ancestors to a table in the database. A separate script then crawls that table and uses tile_flip to expire the tiles
  • 21. PUBLICATION UPDATING AND SEEDING • We have a set of publications, and almost all of our tile requests are for areas around them • The publications have a bounding box, and we have an API for getting the publication data along with it’s location information • Anotherscript running via cron then uses tile_flip to automatically seed an area around each publication at all zoom levels
  • 22. LOW ZOOM LEVEL SEEDING • The low zoom levels are the slowest to render • So, wehave another script that walks levels 10-14 for the entire USA and pre-seeds those tiles using tile_flip
  • 23. STATIC MAPS http://github.com/aub/static_maps/ • Once you have all of this set up, it’s amazingly simple to add other services, like a static map renderer • Mapnik has an excellent Python API you can use • Setting up other services is as simple as writing a Python script and adding another WSGI service to Apache • Our static map service has two endpoints, one for rendering a map centered around a set of points, and the second for returning a JSON response with the pixel positions of those points

Editor's Notes

  1. Configures TileCache to use a disk-based cache Expire sets the expires header in the response for client-side image caching Setting the extension to png256 compresses the tiles more efficiently Issues with meta-tiling across servers
  2. In the cascadenik download, you can find example working OSM stylesheets
  3. This first query is great. Unfortunately, there are 10,561,333 rows in osm_polygon, and the where clause can make it morbidly slow We used triggers that fire as data is added to simulate materialized views and then did our queries against those views, which is much faster
  4. This article explains how to do the basic setup The command: * uses osmosis to pull the latest data * pipes the output, as xml, to osm2pgsql, which appends it to our database * writes an expiration list of all tiles that would have been affected by the update