mapfish 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/COPYING.LESSER ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README ADDED
@@ -0,0 +1,141 @@
1
+ Mapfish server plugin for Ruby on Rails
2
+ =======================================
3
+
4
+ This HowTo describes step by step how to use `MapFish <http://www.mapfish.org/>`_ Server Framework to set up a MapFish project. A MapFish project defines Web Services on which MapFish Client components can rely. See `here <http://trac.mapfish.org/trac/mapfish/wiki/MapFishProtocol>`_ for a description of the interfaces provided by MapFish Web Services.
5
+
6
+ The Mapfish server for Ruby is implemented as a plugin for the `Ruby on Rails <http://www.rubyonrails.org/>`_ framework.
7
+
8
+ A sample application is available at `GitHub <http://github.com/pka/mapfish-rails-sample-app/tree>`_.
9
+
10
+ Create a MapFish project
11
+ ------------------------
12
+
13
+ Create a new Rails project::
14
+
15
+ rails --database=postgresql MyMapFishProject
16
+ cd MyMapFishProject
17
+
18
+ Install the latest version of the Mapfish plugin::
19
+
20
+ ./script/plugin install http://www.mapfish.org/svn/mapfish/implementations/rails-plugin/mapfish/trunk
21
+
22
+ Install the latest version of the Mapfish client libraries::
23
+
24
+ rake mapfish:install_client
25
+
26
+ Install the required plugins and gems::
27
+
28
+ sudo gem install GeoRuby
29
+ ./script/plugin install git://github.com/fragility/spatial_adapter.git
30
+ #For printing:
31
+ sudo gem install Platform
32
+ sudo gem install open4 #Unix only
33
+ sudo gem install win-open3 #Windows only
34
+
35
+ Set up the PostGIS database
36
+ ---------------------------
37
+
38
+ If you don't have PostGIS database template yet, create one::
39
+
40
+ sudo su - postgres
41
+ createdb -E UTF8 template_postgis # Create the template spatial database.
42
+ createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
43
+ psql -d template_postgis -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
44
+ psql -d template_postgis -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql
45
+ cat <<EOS | psql -d template_postgis
46
+ UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';
47
+ REVOKE ALL ON SCHEMA public FROM public;
48
+ GRANT USAGE ON SCHEMA public TO public;
49
+ GRANT ALL ON SCHEMA public TO postgres;
50
+ GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.geometry_columns TO PUBLIC;
51
+ GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.spatial_ref_sys TO PUBLIC;
52
+ VACUUM FULL FREEZE;
53
+ EOS
54
+
55
+ Change the connection properties in ``config/database.yml``.
56
+ Add a line ``template: template_postgis`` for each environment.
57
+
58
+ Create the development database, if it does not exist::
59
+
60
+ rake db:create
61
+
62
+ Set up layers
63
+ -------------
64
+
65
+ You now need to create layers. In effect, a layer corresponds to a PostGIS table.
66
+
67
+ Create a resource (model and controller)::
68
+
69
+ ./script/generate mapfish_resource --skip-timestamps --skip-fixture WeatherStation name:string geom:point
70
+ rake db:migrate
71
+
72
+ Import some data::
73
+
74
+ ./script/runner "Geonames::Weather.weather(:north => 44.1, :south => -9.9, :east => -22.4, :west => 55.2).each { |st| WeatherStation.create(:name => st.stationName, :geom => Point.from_x_y(st.lng, st.lat)) }"
75
+
76
+ (needs lib/geonames.rb from http://github.com/pka/map_layers/tree in lib/)
77
+
78
+ Create a resource for an existing table::
79
+
80
+ ./script/generate mapfish_resource --skip-migration --skip-fixture Country
81
+
82
+ Insert table name and custom id in ``app/models/country.rb``::
83
+
84
+ set_table_name "world_factbk_simplified"
85
+ set_primary_key "gid"
86
+
87
+
88
+
89
+
90
+ Starting the web server
91
+ -----------------------
92
+
93
+ You should be all set now. Try starting the web server::
94
+
95
+ ./script/server
96
+
97
+ and checkout ``http://localhost:3000/countries?maxfeatures=10``
98
+
99
+ Your browser should be displaying a nice GeoJSON object!
100
+
101
+ You can now go back to your webpage and configure MapFish widgets to access your layer through the URL ``http://localhost:3000/countries``.
102
+
103
+
104
+ For running in production mode you should build and install the compressed runtime libraries::
105
+
106
+ rake mapfish:build_scripts
107
+ rake mapfish:copy_scripts
108
+
109
+ The development libraries in public/mfbase are not needed in a production deployment and the
110
+ CSS and Javascript files can be included from public/javascripts::
111
+
112
+ <link rel="stylesheet" type="text/css" href="javascripts/ext/resources/css/ext-all.css" />
113
+ <link rel="stylesheet" type="text/css" href="javascripts/mapfish/mapfish.css" />
114
+
115
+ <script type="text/javascript" src="javascripts/ext/adapter/ext/ext-base.js"></script>
116
+ <script type="text/javascript" src="javascripts/ext/ext-all.js"></script>
117
+ <script type="text/javascript" src="javascripts/mapfish/MapFish.js"></script>
118
+
119
+
120
+ Using the print module
121
+ ----------------------
122
+
123
+ The Rails MapFish plugin can generate a controller for the `MapFish print protocol <http://trac.mapfish.org/trac/mapfish/wiki/PrintModuleDoc#Protocol>`_, to produce PDF outputs of your maps. (see `MapFish PrintModuleDoc <http://trac.mapfish.org/trac/mapfish/wiki/PrintModuleDoc>`_)::
124
+
125
+ ./script/generate print_controller Print
126
+
127
+ You'll need to have `Sun's JRE <http://www.java.com/download/>`_ installed to make this working.
128
+
129
+ * The print module should be ready & responding to /print/info to get print configuration.
130
+ Don't forget to adapt config/print.yaml (see `configuration <http://trac.mapfish.org/trac/mapfish/wiki/PrintModuleServer>`_. For instance, you should at least allow the print service to access the WMS services you're using.
131
+ If you're getting errors, check your log file to get debug information.
132
+
133
+ * Once this is done, you can integrate the `MapFish print widgets <http://www.mapfish.org/svn/mapfish/trunk/MapFish/client/mfbase/mapfish/widgets/print/>`_ into your client application, which give you the ability to output nice customizable PDF with your maps. Examples can be `found here <http://demo.mapfish.org/mapfishsample/trunk/examples/print/>`_.
134
+
135
+
136
+ License
137
+ -------
138
+
139
+ The Mapfish server plugin for Rails is released under the LGPL license.
140
+
141
+ *Copyright (c) 2008 Pirmin Kalberer, Sourcepole AG*
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the mapfish plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the mapfish plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'Mapfish'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ begin
25
+ require 'jeweler'
26
+ Jeweler::Tasks.new do |gemspec|
27
+ gemspec.name = "mapfish"
28
+ gemspec.summary = "Mapfish server plugin for Ruby on Rails"
29
+ gemspec.description = "MapFish is a flexible and complete framework for building rich web-mapping applications. Homepage: mapfish.org"
30
+ gemspec.email = "pka@sourcepole.ch"
31
+ gemspec.homepage = "http://mapfish.org/doc/implementations/rails.html"
32
+ gemspec.authors = ["Pirmin Kalberer"]
33
+ gemspec.add_dependency("spatial_adapter")
34
+ gemspec.add_dependency("POpen4", ">= 0.1.5")
35
+ end
36
+ Jeweler::GemcutterTasks.new
37
+ rescue LoadError
38
+ puts "Jeweler not available. Install it with: gem install jeweler"
39
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.3.0
@@ -0,0 +1,28 @@
1
+ Description:
2
+ Scaffolds an entire MapFish resource, from model and migration to controller,
3
+ along with a full test suite.
4
+
5
+ Pass the name of the model (in singular form), either CamelCased or
6
+ under_scored, as the first argument, and an optional list of attribute
7
+ pairs.
8
+
9
+ Attribute pairs are column_name:sql_type arguments specifying the
10
+ model's attributes. Timestamps are added by default, so you don't have to
11
+ specify them by hand as 'created_at:datetime updated_at:datetime'.
12
+
13
+ You don't have to think up every attribute up front, but it helps to
14
+ sketch out a few so you can start working with the resource immediately.
15
+
16
+ For example, 'mapfish_resource post title:string body:text published:boolean'
17
+ gives you a model with those three attributes, a controller that handles
18
+ the create/show/update/destroy, forms to create and edit your posts, and
19
+ an index that lists them all, as well as a map.resources :posts
20
+ declaration in config/routes.rb.
21
+
22
+ If you want to remove all the generated files, run
23
+ 'script/destroy mapfish_resource ModelName'.
24
+
25
+ Examples:
26
+ `./script/generate mapfish_resource post`
27
+ `./script/generate mapfish_resource post title:string body:text published:boolean`
28
+ `./script/generate mapfish_resource WeatherStation name:string position:point`
@@ -0,0 +1,88 @@
1
+ class MapfishResourceGenerator < Rails::Generator::NamedBase
2
+ default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false
3
+
4
+ attr_reader :controller_name,
5
+ :controller_class_path,
6
+ :controller_file_path,
7
+ :controller_class_nesting,
8
+ :controller_class_nesting_depth,
9
+ :controller_class_name,
10
+ :controller_underscore_name,
11
+ :controller_singular_name,
12
+ :controller_plural_name
13
+ alias_method :controller_file_name, :controller_underscore_name
14
+ alias_method :controller_table_name, :controller_plural_name
15
+
16
+ def initialize(runtime_args, runtime_options = {})
17
+ super
18
+
19
+ if @name == @name.pluralize && !options[:force_plural]
20
+ logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural."
21
+ @name = @name.singularize
22
+ end
23
+
24
+ @controller_name = @name.pluralize
25
+
26
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
27
+ @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
28
+ @controller_singular_name=base_name.singularize
29
+ if @controller_class_nesting.empty?
30
+ @controller_class_name = @controller_class_name_without_nesting
31
+ else
32
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
33
+ end
34
+ end
35
+
36
+ def manifest
37
+ record do |m|
38
+ # Check for class naming collisions.
39
+ m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper")
40
+ m.class_collisions(class_name)
41
+
42
+ # Controller, helper, views, test and stylesheets directories.
43
+ m.directory(File.join('app/models', class_path))
44
+ m.directory(File.join('app/controllers', controller_class_path))
45
+ m.directory(File.join('app/helpers', controller_class_path))
46
+ m.directory(File.join('test/functional', controller_class_path))
47
+ m.directory(File.join('test/unit', class_path))
48
+ m.directory(File.join('test/unit/helpers', class_path))
49
+
50
+ m.template(
51
+ 'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
52
+ )
53
+
54
+ m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
55
+ m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
56
+ #m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
57
+
58
+ m.route_resources controller_file_name
59
+
60
+ m.dependency 'model', [name] + @args, :collision => :skip
61
+ end
62
+ end
63
+
64
+ protected
65
+ # Override with your own usage banner.
66
+ def banner
67
+ "Usage: #{$0} mapfish_resource ModelName [field:type, field:type]"
68
+ end
69
+
70
+ def add_options!(opt)
71
+ opt.separator ''
72
+ opt.separator 'Options:'
73
+ opt.on("--skip-timestamps",
74
+ "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
75
+ opt.on("--skip-migration",
76
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
77
+ opt.on("--force-plural",
78
+ "Forces the generation of a plural ModelName") { |v| options[:force_plural] = v }
79
+ end
80
+
81
+ def scaffold_views
82
+ %w[ index show new edit ]
83
+ end
84
+
85
+ def model_name
86
+ class_name.demodulize
87
+ end
88
+ end