ruby_mapnik 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. data/.autotest +35 -0
  2. data/.gemtest +0 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE +19 -0
  6. data/Manifest.txt +177 -0
  7. data/README.rdoc +84 -0
  8. data/Rakefile +43 -0
  9. data/demo/data/COPYRIGHT.txt +3 -0
  10. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
  11. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
  12. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
  13. data/demo/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
  14. data/demo/data/boundaries.dbf +0 -0
  15. data/demo/data/boundaries.prj +1 -0
  16. data/demo/data/boundaries.sbx +0 -0
  17. data/demo/data/boundaries.shp +0 -0
  18. data/demo/data/boundaries.shx +0 -0
  19. data/demo/data/boundaries_l.dbf +0 -0
  20. data/demo/data/boundaries_l.prj +1 -0
  21. data/demo/data/boundaries_l.sbx +0 -0
  22. data/demo/data/boundaries_l.shp +0 -0
  23. data/demo/data/boundaries_l.shx +0 -0
  24. data/demo/data/ontdrainage.dbf +0 -0
  25. data/demo/data/ontdrainage.prj +1 -0
  26. data/demo/data/ontdrainage.sbx +0 -0
  27. data/demo/data/ontdrainage.shp +0 -0
  28. data/demo/data/ontdrainage.shx +0 -0
  29. data/demo/data/popplaces.dbf +0 -0
  30. data/demo/data/popplaces.prj +1 -0
  31. data/demo/data/popplaces.sbx +0 -0
  32. data/demo/data/popplaces.shp +0 -0
  33. data/demo/data/popplaces.shx +0 -0
  34. data/demo/data/qcdrainage.dbf +0 -0
  35. data/demo/data/qcdrainage.prj +1 -0
  36. data/demo/data/qcdrainage.sbx +0 -0
  37. data/demo/data/qcdrainage.shp +0 -0
  38. data/demo/data/qcdrainage.shx +0 -0
  39. data/demo/data/roads.dbf +0 -0
  40. data/demo/data/roads.prj +1 -0
  41. data/demo/data/roads.sbx +0 -0
  42. data/demo/data/roads.shp +0 -0
  43. data/demo/data/roads.shx +0 -0
  44. data/demo/data/test/charplacement.dbf +0 -0
  45. data/demo/data/test/charplacement.shp +0 -0
  46. data/demo/data/test/charplacement.shx +0 -0
  47. data/demo/data/test/displacement.dbf +0 -0
  48. data/demo/data/test/displacement.shp +0 -0
  49. data/demo/data/test/displacement.shx +0 -0
  50. data/demo/data/test/overlap.dbf +0 -0
  51. data/demo/data/test/overlap.shp +0 -0
  52. data/demo/data/test/overlap.shx +0 -0
  53. data/demo/data/test/raw/charplacement.gfs +25 -0
  54. data/demo/data/test/raw/charplacement.gml +99 -0
  55. data/demo/data/test/raw/charplacement.xsd +36 -0
  56. data/demo/data/test/raw/displacement.gfs +25 -0
  57. data/demo/data/test/raw/displacement.gml +173 -0
  58. data/demo/data/test/raw/displacement.xsd +36 -0
  59. data/demo/data/test/raw/overlap.gfs +25 -0
  60. data/demo/data/test/raw/overlap.gml +127 -0
  61. data/demo/data/test/raw/overlap.xsd +36 -0
  62. data/demo/data/test/raw/textspacing.gfs +25 -0
  63. data/demo/data/test/raw/textspacing.gml +117 -0
  64. data/demo/data/test/raw/textspacing.xsd +36 -0
  65. data/demo/data/test/readme.txt +3 -0
  66. data/demo/data/test/regenerate.sh +20 -0
  67. data/demo/data/test/textspacing.dbf +0 -0
  68. data/demo/data/test/textspacing.shp +0 -0
  69. data/demo/data/test/textspacing.shx +0 -0
  70. data/demo/rundemo.rb +139 -0
  71. data/demo/sinatra/demo.rb +31 -0
  72. data/demo/sinatra/public/css/demo_map.css +7 -0
  73. data/demo/sinatra/public/index.html +13 -0
  74. data/demo/sinatra/public/javascripts/demo_map.js +42 -0
  75. data/ext/ruby_mapnik/_mapnik.cpp +54 -0
  76. data/ext/ruby_mapnik/_mapnik.h +69 -0
  77. data/ext/ruby_mapnik/_mapnik_color.rb.cpp +179 -0
  78. data/ext/ruby_mapnik/_mapnik_color.rb.h +32 -0
  79. data/ext/ruby_mapnik/_mapnik_coord.rb.cpp +145 -0
  80. data/ext/ruby_mapnik/_mapnik_coord.rb.h +32 -0
  81. data/ext/ruby_mapnik/_mapnik_datasource.rb.cpp +150 -0
  82. data/ext/ruby_mapnik/_mapnik_datasource.rb.h +32 -0
  83. data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.cpp +79 -0
  84. data/ext/ruby_mapnik/_mapnik_datasource_cache.rb.h +32 -0
  85. data/ext/ruby_mapnik/_mapnik_envelope.rb.cpp +220 -0
  86. data/ext/ruby_mapnik/_mapnik_envelope.rb.h +32 -0
  87. data/ext/ruby_mapnik/_mapnik_expression.rb.cpp +91 -0
  88. data/ext/ruby_mapnik/_mapnik_expression.rb.h +32 -0
  89. data/ext/ruby_mapnik/_mapnik_feature.rb.cpp +56 -0
  90. data/ext/ruby_mapnik/_mapnik_feature.rb.h +32 -0
  91. data/ext/ruby_mapnik/_mapnik_font_engine.rb.cpp +71 -0
  92. data/ext/ruby_mapnik/_mapnik_font_engine.rb.h +32 -0
  93. data/ext/ruby_mapnik/_mapnik_geometry.rb.cpp +73 -0
  94. data/ext/ruby_mapnik/_mapnik_geometry.rb.h +32 -0
  95. data/ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.cpp +250 -0
  96. data/ext/ruby_mapnik/_mapnik_glyph_symbolizer.rb.h +32 -0
  97. data/ext/ruby_mapnik/_mapnik_layer.rb.cpp +237 -0
  98. data/ext/ruby_mapnik/_mapnik_layer.rb.h +32 -0
  99. data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.cpp +70 -0
  100. data/ext/ruby_mapnik/_mapnik_line_pattern_symbolizer.rb.h +32 -0
  101. data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.cpp +43 -0
  102. data/ext/ruby_mapnik/_mapnik_line_symbolizer.rb.h +32 -0
  103. data/ext/ruby_mapnik/_mapnik_map.rb.cpp +435 -0
  104. data/ext/ruby_mapnik/_mapnik_map.rb.h +32 -0
  105. data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.cpp +139 -0
  106. data/ext/ruby_mapnik/_mapnik_markers_symbolizer.rb.h +32 -0
  107. data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.cpp +147 -0
  108. data/ext/ruby_mapnik/_mapnik_point_symbolizer.rb.h +32 -0
  109. data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.cpp +92 -0
  110. data/ext/ruby_mapnik/_mapnik_polygon_pattern_symbolizer.rb.h +32 -0
  111. data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.cpp +89 -0
  112. data/ext/ruby_mapnik/_mapnik_polygon_symbolizer.rb.h +32 -0
  113. data/ext/ruby_mapnik/_mapnik_projection.rb.cpp +98 -0
  114. data/ext/ruby_mapnik/_mapnik_projection.rb.h +32 -0
  115. data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.cpp +162 -0
  116. data/ext/ruby_mapnik/_mapnik_raster_colorizer.rb.h +32 -0
  117. data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.cpp +53 -0
  118. data/ext/ruby_mapnik/_mapnik_raster_symbolizer.rb.h +32 -0
  119. data/ext/ruby_mapnik/_mapnik_rule.rb.cpp +99 -0
  120. data/ext/ruby_mapnik/_mapnik_rule.rb.h +32 -0
  121. data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.cpp +86 -0
  122. data/ext/ruby_mapnik/_mapnik_shield_symbolizer.rb.h +32 -0
  123. data/ext/ruby_mapnik/_mapnik_stroke.rb.cpp +188 -0
  124. data/ext/ruby_mapnik/_mapnik_stroke.rb.h +32 -0
  125. data/ext/ruby_mapnik/_mapnik_style.rb.cpp +76 -0
  126. data/ext/ruby_mapnik/_mapnik_style.rb.h +32 -0
  127. data/ext/ruby_mapnik/_mapnik_symbolizer.rb.cpp +77 -0
  128. data/ext/ruby_mapnik/_mapnik_symbolizer.rb.h +32 -0
  129. data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.cpp +521 -0
  130. data/ext/ruby_mapnik/_mapnik_text_symbolizer.rb.h +32 -0
  131. data/ext/ruby_mapnik/extconf.rb +78 -0
  132. data/ext/ruby_mapnik/ruby_mapnik.cpp +31 -0
  133. data/lib/ruby_mapnik/mapnik/font_engine.rb +35 -0
  134. data/lib/ruby_mapnik/mapnik/layer.rb +69 -0
  135. data/lib/ruby_mapnik/mapnik/map.rb +144 -0
  136. data/lib/ruby_mapnik/mapnik/projection.rb +46 -0
  137. data/lib/ruby_mapnik/mapnik/raster_colorizer.rb +55 -0
  138. data/lib/ruby_mapnik/mapnik/rule.rb +107 -0
  139. data/lib/ruby_mapnik/mapnik/stroke.rb +58 -0
  140. data/lib/ruby_mapnik/mapnik/style.rb +66 -0
  141. data/lib/ruby_mapnik/mapnik/tile.rb +93 -0
  142. data/lib/ruby_mapnik.rb +48 -0
  143. data/script/console +2 -0
  144. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.dbf +0 -0
  145. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.prj +1 -0
  146. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shp +0 -0
  147. data/test/data/TM_WORLD_BORDERS_SIMPL_0.3_MOD.shx +0 -0
  148. data/test/data/test_map.xml +15 -0
  149. data/test/test_helper.rb +27 -0
  150. data/test/test_line_pattern_symbolizer.rb +26 -0
  151. data/test/test_mapnik_color.rb +66 -0
  152. data/test/test_mapnik_coord.rb +112 -0
  153. data/test/test_mapnik_datasource.rb +49 -0
  154. data/test/test_mapnik_envelope.rb +232 -0
  155. data/test/test_mapnik_expression.rb +19 -0
  156. data/test/test_mapnik_feature.rb +33 -0
  157. data/test/test_mapnik_font_engine.rb +13 -0
  158. data/test/test_mapnik_geometry.rb +72 -0
  159. data/test/test_mapnik_glyph_symbolizer.rb +96 -0
  160. data/test/test_mapnik_layer.rb +137 -0
  161. data/test/test_mapnik_line_symbolizer.rb +25 -0
  162. data/test/test_mapnik_map.rb +191 -0
  163. data/test/test_mapnik_markers_symbolizer.rb +46 -0
  164. data/test/test_mapnik_point_symbolizer.rb +53 -0
  165. data/test/test_mapnik_polygon_symbolizer.rb +44 -0
  166. data/test/test_mapnik_projection.rb +46 -0
  167. data/test/test_mapnik_raster_colorizer.rb +56 -0
  168. data/test/test_mapnik_raster_symbolizer.rb +40 -0
  169. data/test/test_mapnik_rule.rb +63 -0
  170. data/test/test_mapnik_shield_symbolizer.rb +193 -0
  171. data/test/test_mapnik_stroke.rb +94 -0
  172. data/test/test_mapnik_style.rb +28 -0
  173. data/test/test_mapnik_symbolizer.rb +9 -0
  174. data/test/test_mapnik_text_symbolizer.rb +232 -0
  175. data/test/test_polygon_pattern_symbolizer.rb +34 -0
  176. data/test/test_ruby_mapnik.rb +34 -0
  177. data/yard/lib/yard/parser/generic_parser.rb +72 -0
  178. data/yard/lib/yard_generic.rb +18 -0
  179. metadata +322 -0
@@ -0,0 +1,3 @@
1
+ These files are for testing various rendering parts of mapnik, they have been created by hand.
2
+ The raw files are in the raw/ folder (they were created with inkscape to assist!)
3
+ Run the regenerate.sh script to regenerate the shape files from the gml files, this requires ogr2ogr to run.
@@ -0,0 +1,20 @@
1
+ #!/bin/sh
2
+ rm -f textspacing.shp textspacing.shx textspacing.dbf
3
+ ogr2ogr -f "ESRI Shapefile" textspacing raw/textspacing.gml
4
+ mv textspacing/* ./
5
+ rmdir textspacing
6
+
7
+ rm -f overlap.shp overlap.shx overlap.dbf
8
+ ogr2ogr -f "ESRI Shapefile" overlap raw/overlap.gml
9
+ mv overlap/* ./
10
+ rmdir overlap
11
+
12
+ rm -f displacement.shp displacement.shx displacement.dbf
13
+ ogr2ogr -f "ESRI Shapefile" displacement raw/displacement.gml
14
+ mv displacement/* ./
15
+ rmdir displacement
16
+
17
+ rm -f charplacement.shp charplacement.shx charplacement.dbf
18
+ ogr2ogr -f "ESRI Shapefile" charplacement raw/charplacement.gml
19
+ mv charplacement/* ./
20
+ rmdir charplacement
Binary file
Binary file
Binary file
data/demo/rundemo.rb ADDED
@@ -0,0 +1,139 @@
1
+ CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
2
+ require File.join(CURRENT_PATH, '..', 'lib', 'ruby_mapnik')
3
+
4
+ map = Mapnik::Map.new do |m|
5
+
6
+ m.width = 1024
7
+ m.height = 768
8
+ m.background = Mapnik::Color.new("#fff")
9
+ m.srs = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"
10
+
11
+ nd83_srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
12
+
13
+ m.layer "provinces", nd83_srs do |prov|
14
+ prov.datasource = Mapnik::Datasource.create(:type => "shape", :file => File.join(CURRENT_PATH, 'data/boundaries'))
15
+ prov.style do |s|
16
+ s.rule "[NAME_EN] = 'Ontario'" do |ontario|
17
+ ontario.fill = Mapnik::Color.new('#FABEB7')
18
+ end
19
+
20
+ s.rule "[NAME_EN] = 'Quebec'" do |quebec|
21
+ quebec.fill = Mapnik::Color.new('#D9EBCB')
22
+ end
23
+ end
24
+ end
25
+
26
+ m.style 'drainage' do |style|
27
+ style.rule '[HYC] = 8' do |drainage|
28
+ drainage.fill = Mapnik::Color.new('#99CCFF')
29
+ end
30
+ end
31
+
32
+ m.layer "quebec_hydro", nd83_srs do |q_hydro|
33
+ q_hydro.datasource = Mapnik::Datasource.create(:type => "shape", :file => File.join(CURRENT_PATH, 'data/qcdrainage'))
34
+ q_hydro.styles << 'drainage'
35
+ end
36
+
37
+ m.layer "ontario_hydro", nd83_srs do |o_hydro|
38
+ o_hydro.datasource = Mapnik::Datasource.create(:type => "shape", :file => File.join(CURRENT_PATH, 'data/ontdrainage'))
39
+ o_hydro.styles << 'drainage'
40
+ end
41
+
42
+ m.layer "provincial_borders", nd83_srs do |borders|
43
+ borders.datasource = Mapnik::Datasource.create(:type => "shape", :file => File.join(CURRENT_PATH, 'data/boundaries_l'))
44
+ borders.style do |s|
45
+ s.rule do |default|
46
+ default.line do |stroke|
47
+ stroke.color = Mapnik::Color.new('#000')
48
+ stroke.dashes << {:gap => 8, :length => 4}
49
+ stroke.dashes << {:gap => 2, :length => 2}
50
+ stroke.dashes << {:gap => 2, :length => 2}
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ roads_datasource = Mapnik::Datasource.create(:type => "shape", :file => File.join(CURRENT_PATH, 'data/roads'))
57
+ m.layer 'roads_3_and_4', nd83_srs do |layer|
58
+ layer.datasource = roads_datasource
59
+ layer.style do |s|
60
+ s.rule '([CLASS] = 3) or ([CLASS] = 4)' do |road|
61
+ road.line do |stroke|
62
+ stroke.color = Mapnik::Color.new('#AB9E89')
63
+ stroke.width = 2.0
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+ m.layer 'roads_2', nd83_srs do |layer|
70
+ layer.datasource = roads_datasource
71
+
72
+ layer.style 'road_fill' do |s|
73
+ s.rule '[CLASS] = 2' do |road|
74
+ road.line do |stroke|
75
+ stroke.color = Mapnik::Color.new('#AB9E89')
76
+ stroke.width = 4.0
77
+ end
78
+ end
79
+ end
80
+
81
+ layer.style 'road_border' do |s|
82
+ s.rule '[CLASS] = 2' do |road|
83
+ road.line do |stroke|
84
+ stroke.color = Mapnik::Color.new('#FFFA73')
85
+ stroke.width = 2.0
86
+ end
87
+ end
88
+ end
89
+
90
+ end
91
+
92
+ m.layer 'roads_1', nd83_srs do |layer|
93
+ layer.datasource = roads_datasource
94
+
95
+ layer.style 'highway_fill' do |s|
96
+ s.rule '[CLASS] = 1' do |road|
97
+ road.line do |stroke|
98
+ stroke.color = Mapnik::Color.new('#BC951C')
99
+ stroke.width = 7.0
100
+ stroke.line_cap = Mapnik::LineCap::ROUND_CAP
101
+ end
102
+ end
103
+ end
104
+
105
+ layer.style 'highway_border' do |s|
106
+ s.rule '[CLASS] = 1' do |road|
107
+ road.line do |stroke|
108
+ stroke.color = Mapnik::Color.new('#F2BF24')
109
+ stroke.width = 5.0
110
+ stroke.line_cap = Mapnik::LineCap::ROUND_CAP
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ m.layer 'populated_places', nd83_srs do |layer|
117
+ layer.datasource = Mapnik::Datasource.create(:type => "shape", :file => File.join(CURRENT_PATH, 'data/popplaces'))
118
+ layer.style do |style|
119
+ style.rule do |default|
120
+ color = Mapnik::Color.new('#000')
121
+ default.text "[GEONAME]" do |text|
122
+ text.label_placement = Mapnik::LABEL_PLACEMENT::POINT_PLACEMENT
123
+ text.fill = Mapnik::Color.new('#000')
124
+ text.halo_fill = Mapnik::Color.new("#fff")
125
+ text.halo_radius = 1
126
+ text.avoid_edges = true
127
+ end
128
+
129
+ end
130
+ end
131
+ end
132
+
133
+ end
134
+
135
+ # Rendering...
136
+ filename = File.join(CURRENT_PATH, '..', 'tmp', 'rundemo.png')
137
+ map.zoom_to_box(Mapnik::Envelope.new(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855))
138
+ map.render_to_file(filename)
139
+ `open #{filename}`
@@ -0,0 +1,31 @@
1
+ CURRENT_PATH = File.expand_path(File.dirname(__FILE__))
2
+ require 'rubygems'
3
+ require 'sinatra'
4
+ require File.join(CURRENT_PATH, '..', '..', 'lib', 'ruby_mapnik')
5
+
6
+ PATH = File.expand_path(File.dirname(__FILE__))
7
+
8
+
9
+ map = Mapnik::Map.new do |m|
10
+
11
+ m.background = Mapnik::Color.new('#777')
12
+
13
+ m.srs = Mapnik::Tile::DEFAULT_OUTPUT_PROJECTION
14
+
15
+ m.layer 'countries' do |l|
16
+ l.style do |s|
17
+ s.rule do |default|
18
+ default.fill = Mapnik::Color.new('#880000')
19
+ end
20
+ end
21
+ l.srs = "+proj=latlong +datum=WGS84"
22
+ l.datasource = Mapnik::Datasource.create :type => 'shape', :file => "#{PATH}/../data/TM_WORLD_BORDERS_SIMPL_0.3_MOD"
23
+ end
24
+
25
+ end
26
+
27
+ get '/tiles/:zoom/:x/:y.png' do
28
+ tile = Mapnik::Tile.new(params[:zoom], params[:x], params[:y])
29
+ content_type 'image/png', :disposition => 'inline'
30
+ tile.render_to_string(map)
31
+ end
@@ -0,0 +1,7 @@
1
+ #map_canvas{
2
+ bottom: 0;
3
+ left: 0;
4
+ position: absolute;
5
+ right: 0;
6
+ top: 0;
7
+ }
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html>
4
+ <head>
5
+ <link rel="stylesheet" href="/css/demo_map.css" type="text/css" media="screen" charset="utf-8" />
6
+ </head>
7
+ <body>
8
+ <div id="map_canvas"></div>
9
+ <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript" charset="utf-8"></script>
10
+ <script src="javascripts/demo_map.js" type="text/javascript" charset="utf-8"></script>
11
+ </body>
12
+
13
+ </html>
@@ -0,0 +1,42 @@
1
+ function CoordMapType() {
2
+ }
3
+
4
+ CoordMapType.prototype.tileSize = new google.maps.Size(256,256);
5
+ CoordMapType.prototype.maxZoom = 19;
6
+
7
+ CoordMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
8
+ var div = ownerDocument.createElement('DIV');
9
+ div.style.width = this.tileSize.width + 'px';
10
+ div.style.height = this.tileSize.height + 'px';
11
+ div.style.opacity = '1';
12
+ div.style.backgroundImage = 'url(http://localhost:4567/tiles/' + zoom + '/' + coord.x + '/' + coord.y + '.png)';
13
+ return div;
14
+ };
15
+
16
+ CoordMapType.prototype.name = "Tile #s";
17
+ CoordMapType.prototype.alt = "Tile Coordinate Map Type";
18
+
19
+ var map;
20
+ var chicago = new google.maps.LatLng(41.850033,-87.6500523);
21
+ var coordinateMapType = new CoordMapType();
22
+
23
+ function initialize() {
24
+ var mapOptions = {
25
+ zoom: 10,
26
+ center: chicago// ,
27
+ // mapTypeId: google.maps.MapTypeId.ROADMAP
28
+ };
29
+
30
+ map = new google.maps.Map(document.getElementById("map_canvas"),
31
+ mapOptions);
32
+
33
+ // Now attach the coordinate map type to the map's registry
34
+ map.mapTypes.set('coordinate', coordinateMapType);
35
+
36
+ map.setMapTypeId('coordinate');
37
+
38
+ // We can now set the map to use the 'coordinate' map type
39
+ // map.overlayMapTypes.insertAt(0, new CoordMapType());
40
+ }
41
+
42
+ initialize();
@@ -0,0 +1,54 @@
1
+ /*****************************************************************************
2
+ Copyright (C) 2011 Elliot Laster
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the ‘Software’), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ *****************************************************************************/
22
+ #include "_mapnik.h"
23
+
24
+ void register_mapnik(){
25
+ Rice::Module rb_mapnik = Rice::define_module("Mapnik");
26
+
27
+ register_color(rb_mapnik);
28
+ register_coord(rb_mapnik);
29
+ register_datasource(rb_mapnik);
30
+ register_datasource_cache(rb_mapnik);
31
+ register_envelope(rb_mapnik);
32
+ register_feature(rb_mapnik);
33
+ register_geometry(rb_mapnik);
34
+ register_polygon_symbolizer(rb_mapnik);
35
+ register_line_symbolizer(rb_mapnik);
36
+ register_stroke(rb_mapnik);
37
+ register_rule(rb_mapnik);
38
+ register_expression(rb_mapnik);
39
+ register_symbolizer(rb_mapnik);
40
+ register_style(rb_mapnik);
41
+ register_layer(rb_mapnik);
42
+ register_map(rb_mapnik);
43
+ register_projection(rb_mapnik);
44
+ register_text_symbolizer(rb_mapnik);
45
+ register_font_engine(rb_mapnik);
46
+ register_raster_symbolizer(rb_mapnik);
47
+ register_raster_colorizer(rb_mapnik);
48
+ register_point_symbolizer(rb_mapnik);
49
+ register_polygon_pattern_symbolizer(rb_mapnik);
50
+ register_glyph_symbolizer(rb_mapnik);
51
+ register_line_pattern_symbolizer(rb_mapnik);
52
+ register_markers_symbolizer(rb_mapnik);
53
+ register_shield_symbolizer(rb_mapnik);
54
+ }
@@ -0,0 +1,69 @@
1
+ /*****************************************************************************
2
+ Copyright (C) 2011 Elliot Laster
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the ‘Software’), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ *****************************************************************************/
22
+ #ifndef mapnik_HPP
23
+ #define mapnik_HPP
24
+
25
+ // Rice
26
+ #include <rice/Enum.hpp>
27
+ #include <rice/Object.hpp>
28
+ #include <rice/Data_Type.hpp>
29
+ #include <rice/Data_Object.hpp>
30
+ #include <rice/Allocation_Strategies.hpp>
31
+ #include <rice/Module.hpp>
32
+ #include <rice/Enum.hpp>
33
+
34
+ // Ruby Mapnik
35
+ #include "_mapnik_color.rb.h"
36
+ #include "_mapnik_coord.rb.h"
37
+ #include "_mapnik_datasource.rb.h"
38
+ #include "_mapnik_datasource_cache.rb.h"
39
+ #include "_mapnik_envelope.rb.h"
40
+ #include "_mapnik_feature.rb.h"
41
+ #include "_mapnik_geometry.rb.h"
42
+
43
+ #include "_mapnik_polygon_symbolizer.rb.h"
44
+ #include "_mapnik_line_symbolizer.rb.h"
45
+ #include "_mapnik_stroke.rb.h"
46
+ #include "_mapnik_rule.rb.h"
47
+
48
+ #include "_mapnik_expression.rb.h"
49
+ #include "_mapnik_symbolizer.rb.h"
50
+ #include "_mapnik_style.rb.h"
51
+ #include "_mapnik_layer.rb.h"
52
+ #include "_mapnik_map.rb.h"
53
+
54
+ #include "_mapnik_projection.rb.h"
55
+ #include "_mapnik_text_symbolizer.rb.h"
56
+ #include "_mapnik_font_engine.rb.h"
57
+ #include "_mapnik_raster_symbolizer.rb.h"
58
+ #include "_mapnik_raster_colorizer.rb.h"
59
+ #include "_mapnik_point_symbolizer.rb.h"
60
+ #include "_mapnik_polygon_pattern_symbolizer.rb.h"
61
+ #include "_mapnik_glyph_symbolizer.rb.h"
62
+ #include "_mapnik_line_pattern_symbolizer.rb.h"
63
+ #include "_mapnik_markers_symbolizer.rb.h"
64
+ #include "_mapnik_shield_symbolizer.rb.h"
65
+
66
+
67
+ void register_mapnik();
68
+
69
+ #endif
@@ -0,0 +1,179 @@
1
+ /*****************************************************************************
2
+ Copyright (C) 2011 Elliot Laster
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the ‘Software’), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ *****************************************************************************/
22
+
23
+ #include "_mapnik_color.rb.h"
24
+
25
+ // Rice
26
+ #include <rice/Data_Type.hpp>
27
+ #include <rice/Constructor.hpp>
28
+ #include <rice/Class.hpp>
29
+
30
+ // Mapnik
31
+ #include <mapnik/color.hpp>
32
+
33
+ namespace {
34
+ bool check_color_equality(mapnik::color const & self, mapnik::color const & rhs){
35
+ return self == rhs;
36
+ }
37
+
38
+ // All this for optional constructor arguments. There must be a better way...
39
+ void initialize_color(Rice::Object self, Rice::Object arg1 = Rice::Object(), Rice::Object arg2 = Rice::Object(), Rice::Object arg3 = Rice::Object(), Rice::Object arg4 = Rice::Object()){
40
+ if(arg1.rb_type() == T_STRING && arg2.is_nil() && arg3.is_nil() && arg4.is_nil())
41
+ {
42
+ std::string hex = from_ruby<std::string>(arg1);
43
+ DATA_PTR(self.value()) = new mapnik::color(hex);
44
+ } else if(arg1.is_nil() && arg2.is_nil() && arg3.is_nil() && arg4.is_nil())
45
+ {
46
+ DATA_PTR(self.value()) = new mapnik::color();
47
+ } else if(arg1.rb_type() == T_FIXNUM && arg2.rb_type() == T_FIXNUM && arg3.rb_type() == T_FIXNUM && arg4.rb_type() == T_FIXNUM)
48
+ {
49
+ DATA_PTR(self.value()) = new mapnik::color((int)NUM2INT(arg1.value()), (int)NUM2INT(arg2.value()), (int)NUM2INT(arg3.value()), (int)NUM2INT(arg4.value()));
50
+ } else if(arg1.rb_type() == T_FIXNUM && arg2.rb_type() == T_FIXNUM && arg3.rb_type() == T_FIXNUM && arg4.is_nil())
51
+ {
52
+ DATA_PTR(self.value()) = new mapnik::color((int)NUM2INT(arg1.value()), (int)NUM2INT(arg2.value()), (int)NUM2INT(arg3.value()));
53
+ } else
54
+ {
55
+ rb_raise(rb_eRuntimeError, "Could not instantiate color");
56
+ }
57
+ }
58
+ }
59
+ void register_color(Rice::Module rb_mapnik){
60
+ /*
61
+ @@Module_var rb_mapnik = Mapnik
62
+ */
63
+
64
+ /*
65
+ * Document-class: Mapnik::Color
66
+ * A RGBA color.
67
+ */
68
+ Rice::Data_Type< mapnik::color > rb_ccolor = Rice::define_class_under< mapnik::color >(rb_mapnik, "Color");
69
+
70
+ /*
71
+ * Document-method: new
72
+ * call-seq:
73
+ * new()
74
+ * new(red, green, blue)
75
+ * new(red, green, blues, alpha)
76
+ * new(css_string)
77
+ * @return [Mapnik::Color]
78
+ * Returns a new Color object. The first form returns a value of white
79
+ * (255, 255, 255, 255), the others set the values properly.
80
+ *
81
+ * The CSS String form
82
+ * should be of the format "#FF0000" (leading '#').
83
+ */
84
+ rb_ccolor.define_constructor(Rice::Constructor< mapnik::color >());
85
+
86
+ rb_ccolor.define_method("initialize", &initialize_color, (Rice::Arg("arg1") = Rice::Object(), Rice::Arg("arg2") = Rice::Object(), Rice::Arg("arg3") = Rice::Object(), Rice::Arg("arg4") = Rice::Object()));
87
+
88
+ /*
89
+ * Document-method: red
90
+ * Returns the red value of the color as an integer value between 0 and 255
91
+ * @return [Integer]
92
+ */
93
+ rb_ccolor.define_method("red", &mapnik::color::red);
94
+
95
+ /*
96
+ * Document-method: green
97
+ * Returns the green value of the color as an integer value between 0 and 255
98
+ * @return [Integer]
99
+ */
100
+ rb_ccolor.define_method("green", &mapnik::color::green);
101
+
102
+ /*
103
+ * Document-method: blue
104
+ * Returns the blue value of the color as an integer value between 0 and 255
105
+ * @return [Integer]
106
+ */
107
+ rb_ccolor.define_method("blue", &mapnik::color::blue);
108
+
109
+ /*
110
+ * Document-method: alpha
111
+ * Returns the alpha value of the color as an integer value between 0 and 255
112
+ * @return [Integer]
113
+ */
114
+ rb_ccolor.define_method("alpha", &mapnik::color::alpha);
115
+
116
+ /*
117
+ * Document-method: red=
118
+ * call-seq:
119
+ * red=(value)
120
+ * @param [Integer] value between 0 and 255
121
+ * @return [nil]
122
+ * Sets the red value of the color
123
+ */
124
+ rb_ccolor.define_method("red=", &mapnik::color::set_red, (Rice::Arg("value")));
125
+
126
+ /*
127
+ * Document-method: green=
128
+ * call-seq:
129
+ * green=(value)
130
+ * @param [Integer] value between 0 and 255
131
+ * @return [nil]
132
+ * Sets the green value of the color
133
+ */
134
+ rb_ccolor.define_method("green=", &mapnik::color::set_green, (Rice::Arg("value")));
135
+
136
+ /*
137
+ * Document-method: blue=
138
+ * call-seq:
139
+ * blue=(value)
140
+ * @param [Integer] value between 0 and 255
141
+ * @return [nil]
142
+ * Sets the blue value of the color
143
+ */
144
+ rb_ccolor.define_method("blue=", &mapnik::color::set_blue, (Rice::Arg("value")));
145
+
146
+ /*
147
+ * Document-method: alpha=
148
+ * call-seq:
149
+ * alpha=(value)
150
+ * @param [Integer] value between 0 and 255
151
+ * @return [nil]
152
+ * Sets the alpha value of the color
153
+ */
154
+ rb_ccolor.define_method("alpha=", &mapnik::color::set_alpha, (Rice::Arg("value")));
155
+
156
+ /*
157
+ * Document-method: to_hex
158
+ * Returns a string with a CSS hex value representing the color
159
+ * @return [String] the CSS hex color string
160
+ */
161
+ rb_ccolor.define_method("to_hex", &mapnik::color::to_hex_string);
162
+
163
+ /*
164
+ * Document-method: to_s
165
+ * Returns a string with rgb(a) values representing the color
166
+ * @return [String] RGBA values like so: "rgb(0,0,0)"
167
+ */
168
+ rb_ccolor.define_method("to_s", &mapnik::color::to_string);
169
+
170
+ /*
171
+ * Document-method: ==
172
+ * call-seq:
173
+ * == another_color
174
+ * Returns true if the red, blue, green, and alpha values are equal for both colors
175
+ * @return [boolean]
176
+ */
177
+ rb_ccolor.define_method("==", &check_color_equality);
178
+
179
+ }
@@ -0,0 +1,32 @@
1
+ /*****************************************************************************
2
+ Copyright (C) 2011 Elliot Laster
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ this software and associated documentation files (the ‘Software’), to deal in
6
+ the Software without restriction, including without limitation the rights to
7
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
+ of the Software, and to permit persons to whom the Software is furnished to do
9
+ so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
21
+ *****************************************************************************/
22
+ #ifndef PIKA2_MAPNIK_COLOR
23
+ #define PIKA2_MAPNIK_COLOR
24
+
25
+ namespace Rice
26
+ {
27
+ class Module;
28
+ }
29
+
30
+ void register_color(Rice::Module rb_mapnik);
31
+
32
+ #endif