Skip to content

Instantly share code, notes, and snippets.

View springmeyer's full-sized avatar

Dane Springmeyer springmeyer

View GitHub Profile
@springmeyer
springmeyer / mapnik-save-map-to-xml-string.py
Created May 23, 2013 16:57
Example of using the Mapnik python API to save a map constructed in python into an XML string or file
>>> import mapnik
>>> m = mapnik.Map(256,256)
>>> m.background = mapnik.Color('green')
>>> print mapnik.save_map_to_string(m)
<?xml version="1.0" encoding="utf-8"?>
<Map srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" background-color="rgb(0,128,0)"/>
>>> mapnik.save_map(m,'file.xml')
@springmeyer
springmeyer / mapnik-bbox-expansion.py
Created May 16, 2013 17:59
Example demonstrating collecting a list of points into a mapnik.Box2d and then slightly expanding it
import mapnik
points = [[-122,48],[-120,45],[-90,43]]
bbox = None
for idx, point in enumerate(points):
if idx == 0:
bbox = mapnik.Box2d(point[0],point[1],point[0],point[1])
else:
@springmeyer
springmeyer / node-mapnik-only-gyp.txt
Created May 16, 2013 02:24
node-mapnik windows compile with pure gyp
c:\dev2\node-mapnik>set PROJ_LIB=C:\dev2\proj\nad
c:\dev2\node-mapnik>set GDAL_DATA=C:\dev2\gdal\data
c:\dev2\node-mapnik>set MAPNIK_INPUT_PLUGINS_DIRECTORY="c:\\mapnik-2.0\\lib\\mapnik\\input"
c:\dev2\node-mapnik>set MAPNIK_FONT_DIRECTORY="c:\\mapnik-2.0\\lib\\mapnik\\fonts"
c:\dev2\node-mapnik>rd /q /s Default
@springmeyer
springmeyer / node-mapnik-node-gyp.txt
Created May 16, 2013 02:23
node-mapnik compile with node-gyp on windows (npm --verbose install)
> mapnik@1.0.0 install c:\dev2\node-mapnik
> node-gyp rebuild
c:\dev2\node-mapnik>node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
Build started 5/15/2013 7:16:32 PM.
Project "c:\dev2\node-mapnik\build\binding.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Release|Win32".
@springmeyer
springmeyer / cache-api.js
Last active December 17, 2015 03:09
marker cache api in node-mapnik
// MarkerCache is a singleton so does not need to be created
var mc = mapnik.MarkerCache;
// size
// should always report `2` since there are `2` built-in markers (ellipse and arrow)
mc.size();
// keys
// should report the keys of the `2` built-in markers
> mc.keys();
@springmeyer
springmeyer / utils.hpp.diff
Created May 6, 2013 19:44
make the mapnik singleton publicly visible
diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp
index 24a5d3d..01cf84a 100644
--- a/include/mapnik/utils.hpp
+++ b/include/mapnik/utils.hpp
@@ -23,6 +23,8 @@
#ifndef MAPNIK_UTILS_HPP
#define MAPNIK_UTILS_HPP
+#include <mapnik/config.hpp>
+
@springmeyer
springmeyer / mapnik-geometry-example.py
Created April 19, 2013 21:55
example of working with geojson, wkt, and wkb in mapnik python api
>>> import mapnik
>>> path = mapnik.Path.from_geojson('{ "type":"Point","coordinates":[-122,48] }')
>>> path.envelope()
Box2d(-122.0,48.0,-122.0,48.0)
>>> path.to_geojson()
'{"type":"Point","coordinates":[-122,48]}'
>>> path.to_wkt()
'Point(-122 48)'
>>> path.to_wkb(mapnik.wkbByteOrder.NDR)
'\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80^\xc0\x00\x00\x00\x00\x00\x00H@'
@springmeyer
springmeyer / 2.1.1.txt
Last active December 16, 2015 03:08
is null empty string regression in mapnik 2.2-pre
'' != null: False
0 != null: False
null != null: False
----------
'' = null: False
0 = null: False
null = null: False
----------
'' != '': False
0 != '': True
git clone --depth 1 git@github.com:mapnik/mapnik-packaging.git
cd mapnik-packaging/osx
source MacOSX.sh
git clone --depth 1 git@github.com:mapnik/mapnik.git
./scripts/download_deps.sh
./scripts/build_core_deps.sh
./scripts/build_mapnik_ios.sh
export PATH=${MAPNIK_BIN_SOURCE}/bin:$PATH
curl -O https://gist.github.com/springmeyer/5359567/raw/e53361a7fa88c7d647fd8cdabefa834334389ffd/image-reader-test.cpp
clang++ -o image-reader-test image-reader-test.cpp `mapnik-config --cxxflags --defines --includes --libs --ldflags --dep-libs`
@springmeyer
springmeyer / image-reader-test.cpp
Created April 11, 2013 00:09
image reader test
#include <iostream>
#include <mapnik/image_reader.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/graphics.hpp>
#include <mapnik/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
/*