kopia lustrzana https://github.com/hholzgra/ocitysmap
Rename OCitySMap Python module from ocitysmap2 to ocitysmap
Renamed ocitysmap2-render as render.py since we don't need/want "ocitysmap2" in the name anymore. Rename conf template as ocitysmap.conf.dist for the same reason. Updated INSTALL instructions accordingly. Signed-off-by: Maxime Petazzoni <maxime.petazzoni@bulix.org>stable
rodzic
e415b30707
commit
1aa5c5b068
|
@ -1,7 +1,6 @@
|
||||||
*~
|
*~
|
||||||
*.mo
|
*.mo
|
||||||
/ocitysmap.conf.mine
|
/ocitysmap.conf
|
||||||
/support/planet-update-daily.sh
|
|
||||||
/support/shoreline-update.sh
|
/support/shoreline-update.sh
|
||||||
/stylesheet/maposmatic-printable/inc/datasource-settings.xml.inc
|
/stylesheet/maposmatic-printable/inc/datasource-settings.xml.inc
|
||||||
/stylesheet/maposmatic-printable/inc/fontset-settings.xml.inc
|
/stylesheet/maposmatic-printable/inc/fontset-settings.xml.inc
|
||||||
|
|
24
INSTALL
24
INSTALL
|
@ -238,8 +238,8 @@ are using. They have been tested on several x86_64 hosts.
|
||||||
d. Configuration
|
d. Configuration
|
||||||
|
|
||||||
python ./generate_xml.py --dbname maposmatic --host 'localhost' \
|
python ./generate_xml.py --dbname maposmatic --host 'localhost' \
|
||||||
--user maposmatic --port 5432 \
|
--user maposmatic --port 5432 \
|
||||||
--password 'ereiamjh'
|
--password 'ereiamjh'
|
||||||
|
|
||||||
11. Installation of OCitySMap
|
11. Installation of OCitySMap
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ are using. They have been tested on several x86_64 hosts.
|
||||||
d. Configuration file
|
d. Configuration file
|
||||||
|
|
||||||
Create a ~/.ocitysmap.conf configuration file, modeled after the
|
Create a ~/.ocitysmap.conf configuration file, modeled after the
|
||||||
provided ocitysmap2.conf-template file.
|
provided ocitysmap2.conf.dist file.
|
||||||
|
|
||||||
12. Run OCitySMap
|
12. Run OCitySMap
|
||||||
|
|
||||||
|
@ -290,10 +290,10 @@ Appendix A: Installation of maposmatic-printable stylesheet
|
||||||
cd stylesheet/maposmatic-printable/
|
cd stylesheet/maposmatic-printable/
|
||||||
|
|
||||||
python ./generate_xml.py --dbname maposmatic --host 'localhost' \
|
python ./generate_xml.py --dbname maposmatic --host 'localhost' \
|
||||||
--user maposmatic --port 5432 \
|
--user maposmatic --port 5432 \
|
||||||
--password 'ereiamjh' \
|
--password 'ereiamjh' \
|
||||||
--world_boundaries mapnik2-osm/world_boundaries \
|
--world_boundaries mapnik2-osm/world_boundaries \
|
||||||
--symbols mapnik2-osm/symbols
|
--symbols mapnik2-osm/symbols
|
||||||
|
|
||||||
Appendix B: installation of the MapQuest stylesheet
|
Appendix B: installation of the MapQuest stylesheet
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
@ -351,11 +351,11 @@ replace "Arial" by "DejaVu".
|
||||||
Create the .inc files from the templates:
|
Create the .inc files from the templates:
|
||||||
|
|
||||||
python /path/to/mapnik2-osm/generate_xml.py --inc mapquest_inc \
|
python /path/to/mapnik2-osm/generate_xml.py --inc mapquest_inc \
|
||||||
--symbols mapquest_symbols \
|
--symbols mapquest_symbols \
|
||||||
--dbname maposmatic \
|
--dbname maposmatic \
|
||||||
--host 'localhost' \
|
--host 'localhost' \
|
||||||
--user maposmatic --port 5432 \
|
--user maposmatic --port 5432 \
|
||||||
--password 'ereiamjh'
|
--password 'ereiamjh'
|
||||||
|
|
||||||
The final step is to integrate this new stylesheet in ocitysmap. To do
|
The final step is to integrate this new stylesheet in ocitysmap. To do
|
||||||
so, edit your ~/.ocitysmap.conf file, and add a new stylesheet
|
so, edit your ~/.ocitysmap.conf file, and add a new stylesheet
|
||||||
|
|
6
i18n.py
6
i18n.py
|
@ -32,9 +32,9 @@ def make_pot():
|
||||||
print "Make locale/ocitysmap.pot"
|
print "Make locale/ocitysmap.pot"
|
||||||
subprocess.check_call(['xgettext', '-o', 'ocitysmap.pot', '-p', 'locale',
|
subprocess.check_call(['xgettext', '-o', 'ocitysmap.pot', '-p', 'locale',
|
||||||
'-L', 'Python',
|
'-L', 'Python',
|
||||||
'ocitysmap2/indexlib/indexer.py',
|
'ocitysmap/indexlib/indexer.py',
|
||||||
'ocitysmap2/layoutlib/multi_page_renderer.py',
|
'ocitysmap/layoutlib/multi_page_renderer.py',
|
||||||
'ocitysmap2/layoutlib/single_page_renderers.py'])
|
'ocitysmap/layoutlib/single_page_renderers.py'])
|
||||||
return
|
return
|
||||||
|
|
||||||
def make_po(languages):
|
def make_po(languages):
|
||||||
|
|
|
@ -38,27 +38,27 @@ How to use OCitySMap?
|
||||||
|
|
||||||
The API of OCitySMap is very simple. First, you need to instanciate the main
|
The API of OCitySMap is very simple. First, you need to instanciate the main
|
||||||
OCitySMap class with the path to your OCitySMap configuration file (see
|
OCitySMap class with the path to your OCitySMap configuration file (see
|
||||||
ocitysmap.conf-template):
|
ocitysmap.conf.dist):
|
||||||
|
|
||||||
|
|
||||||
ocitysmap = ocitysmap2.OCitySMap('/path/to/your/config')
|
renderer = ocitysmap.OCitySMap('/path/to/your/config')
|
||||||
|
|
||||||
The next step is to create a RenderingConfiguration, the object that
|
The next step is to create a RenderingConfiguration, the object that
|
||||||
encapsulates all the information to parametize the rendering, including the
|
encapsulates all the information to parametize the rendering, including the
|
||||||
Mapnik stylesheet. You can retrieve the list of supported stylesheets (directly
|
Mapnik stylesheet. You can retrieve the list of supported stylesheets (directly
|
||||||
as Stylesheet objects) with:
|
as Stylesheet objects) with:
|
||||||
|
|
||||||
styles = ocitysmap.get_all_style_configurations()
|
styles = renderer.get_all_style_configurations()
|
||||||
|
|
||||||
Fill in your RenderingConfiguration with the map title, the OSM ID or bounding
|
Fill in your RenderingConfiguration with the map title, the OSM ID or bounding
|
||||||
box, the chosen map language, the Stylesheet object and the paper size (in
|
box, the chosen map language, the Stylesheet object and the paper size (in
|
||||||
millimeters) and simply pass it to OCitySMap's render method:
|
millimeters) and simply pass it to OCitySMap's render method:
|
||||||
|
|
||||||
ocitysmap.render(rendering_configuration, layout_name,
|
renderer.render(rendering_configuration, layout_name,
|
||||||
output_formats, prefix)
|
output_formats, prefix)
|
||||||
|
|
||||||
The layout name is the renderer's key name. You can get the list of all
|
The layout name is the renderer's key name. You can get the list of all
|
||||||
supported renderers with ocitysmap.get_all_renderers(). The output_formats is a
|
supported renderers with renderer.get_all_renderers(). The output_formats is a
|
||||||
list of output formats. For now, the following formats are supported:
|
list of output formats. For now, the following formats are supported:
|
||||||
|
|
||||||
* PNG at 72dpi
|
* PNG at 72dpi
|
||||||
|
@ -83,17 +83,14 @@ import os
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import re
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import shapely
|
import shapely
|
||||||
import shapely.wkt
|
import shapely.wkt
|
||||||
import shapely.geometry
|
import shapely.geometry
|
||||||
|
|
||||||
import coords
|
import coords
|
||||||
import i18n
|
import i18n
|
||||||
|
|
||||||
from indexlib.indexer import StreetIndex
|
from indexlib.indexer import StreetIndex
|
||||||
from indexlib.commons import IndexDoesNotFitError, IndexEmptyError
|
from indexlib.commons import IndexDoesNotFitError, IndexEmptyError
|
||||||
|
|
||||||
from layoutlib import PAPER_SIZES, renderers
|
from layoutlib import PAPER_SIZES, renderers
|
||||||
import layoutlib.commons
|
import layoutlib.commons
|
||||||
|
|
||||||
|
@ -167,6 +164,9 @@ class Stylesheet:
|
||||||
|
|
||||||
s.name = parser.get(section_name, 'name')
|
s.name = parser.get(section_name, 'name')
|
||||||
s.path = parser.get(section_name, 'path')
|
s.path = parser.get(section_name, 'path')
|
||||||
|
if not os.path.exists(s.path):
|
||||||
|
raise ValueError, \
|
||||||
|
'Could not find stylesheet file for stylesheet %s!' % s.name
|
||||||
assign_if_present('description')
|
assign_if_present('description')
|
||||||
|
|
||||||
assign_if_present('grid_line_color')
|
assign_if_present('grid_line_color')
|
||||||
|
@ -217,7 +217,7 @@ class OCitySMap:
|
||||||
config_files = [config_files]
|
config_files = [config_files]
|
||||||
|
|
||||||
config_files = map(os.path.expanduser, config_files)
|
config_files = map(os.path.expanduser, config_files)
|
||||||
LOG.info('Reading OCitySMap configuration from %s...' %
|
LOG.debug('Reading OCitySMap configuration from %s...' %
|
||||||
', '.join(config_files))
|
', '.join(config_files))
|
||||||
|
|
||||||
self._parser = ConfigParser.RawConfigParser()
|
self._parser = ConfigParser.RawConfigParser()
|
||||||
|
@ -229,8 +229,7 @@ class OCitySMap:
|
||||||
|
|
||||||
# Read stylesheet configuration
|
# Read stylesheet configuration
|
||||||
self.STYLESHEET_REGISTRY = Stylesheet.create_all_from_config(self._parser)
|
self.STYLESHEET_REGISTRY = Stylesheet.create_all_from_config(self._parser)
|
||||||
LOG.debug('Found %d Mapnik stylesheets.'
|
LOG.debug('Found %d Mapnik stylesheets.' % len(self.STYLESHEET_REGISTRY))
|
||||||
% len(self.STYLESHEET_REGISTRY))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _db(self):
|
def _db(self):
|
|
@ -26,7 +26,8 @@
|
||||||
import cairo
|
import cairo
|
||||||
import pango
|
import pango
|
||||||
import pangocairo
|
import pangocairo
|
||||||
import ocitysmap2.layoutlib.commons as commons
|
|
||||||
|
import ocitysmap.layoutlib.commons as commons
|
||||||
|
|
||||||
def draw_text(ctx, pc, layout, fascent, fheight,
|
def draw_text(ctx, pc, layout, fascent, fheight,
|
||||||
baseline_x, baseline_y, text, pango_alignment):
|
baseline_x, baseline_y, text, pango_alignment):
|
|
@ -23,30 +23,29 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import os
|
|
||||||
import string
|
|
||||||
import random
|
|
||||||
import psycopg2
|
|
||||||
import cairo
|
import cairo
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
import psycopg2
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
from ocitysmap import i18n, coords
|
||||||
|
from ocitysmap.maplib.grid import Grid
|
||||||
from ocitysmap2 import i18n, coords
|
|
||||||
from ocitysmap2.maplib.grid import Grid
|
|
||||||
|
|
||||||
from indexer import StreetIndex
|
from indexer import StreetIndex
|
||||||
from renderer import StreetIndexRenderer
|
from renderer import StreetIndexRenderer
|
||||||
from commons import IndexCategory, IndexItem
|
from commons import IndexCategory, IndexItem
|
||||||
|
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
random.seed(42)
|
random.seed(42)
|
||||||
|
|
||||||
lang = "fr_FR.UTF-8"
|
lang = "fr_FR.UTF-8"
|
||||||
#lang = "ar_MA.UTF-8"
|
#lang = "ar_MA.UTF-8"
|
||||||
#lang = "zh_CN.utf8"
|
#lang = "zh_CN.utf8"
|
||||||
i18n = i18n.install_translation(lang,
|
i18n = i18n.install_translation(lang,
|
||||||
os.path.join(os.path.dirname(__file__),
|
os.path.join(os.path.dirname(__file__),
|
||||||
"..", "..", "locale"))
|
"..", "..", "locale"))
|
||||||
|
|
||||||
bbox = coords.BoundingBox(48.8162, 2.3417, 48.8063, 2.3699) # France
|
bbox = coords.BoundingBox(48.8162, 2.3417, 48.8063, 2.3699) # France
|
||||||
#bbox = coords.BoundingBox(34.0322, -6.8648, 34.0073, -6.8133) # Moroco
|
#bbox = coords.BoundingBox(34.0322, -6.8648, 34.0073, -6.8133) # Moroco
|
|
@ -22,12 +22,14 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
import pango
|
import pango
|
||||||
|
import sys
|
||||||
|
|
||||||
import os, sys
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
import draw_utils
|
import draw_utils
|
||||||
|
|
||||||
|
|
||||||
class IndexEmptyError(Exception):
|
class IndexEmptyError(Exception):
|
||||||
"""This exception is raised when no data is to be rendered in the index."""
|
"""This exception is raised when no data is to be rendered in the index."""
|
||||||
pass
|
pass
|
||||||
|
@ -206,7 +208,7 @@ class IndexItem:
|
||||||
Update the location_str field from the given Grid object.
|
Update the location_str field from the given Grid object.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
grid (ocitysmap2.Grid): the Grid object from which we
|
grid (ocitysmap.Grid): the Grid object from which we
|
||||||
compute the location strings
|
compute the location strings
|
||||||
|
|
||||||
Returns:
|
Returns:
|
|
@ -23,15 +23,13 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import locale
|
|
||||||
import psycopg2
|
|
||||||
import csv
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
import locale
|
||||||
import commons
|
import logging
|
||||||
from ocitysmap2 import coords
|
import os
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
# compatibility with django: see http://code.djangoproject.com/ticket/5996
|
# compatibility with django: see http://code.djangoproject.com/ticket/5996
|
||||||
|
@ -39,6 +37,8 @@ psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
||||||
# SQL string escaping routine
|
# SQL string escaping routine
|
||||||
_sql_escape_unicode = lambda s: psycopg2.extensions.adapt(s.encode('utf-8'))
|
_sql_escape_unicode = lambda s: psycopg2.extensions.adapt(s.encode('utf-8'))
|
||||||
|
|
||||||
|
import commons
|
||||||
|
import ocitysmap
|
||||||
|
|
||||||
l = logging.getLogger('ocitysmap')
|
l = logging.getLogger('ocitysmap')
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class StreetIndex:
|
||||||
mapping them onto the given grid.
|
mapping them onto the given grid.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
grid (ocitysmap2.Grid): the Grid object from which we
|
grid (ocitysmap.Grid): the Grid object from which we
|
||||||
compute the location strings
|
compute the location strings
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -232,8 +232,8 @@ class StreetIndex:
|
||||||
l.exception("Error parsing %s for %s" % (repr(linestring),
|
l.exception("Error parsing %s for %s" % (repr(linestring),
|
||||||
repr(street_name)))
|
repr(street_name)))
|
||||||
raise
|
raise
|
||||||
endpoint1 = coords.Point(s_endpoint1[1], s_endpoint1[0])
|
endpoint1 = ocitysmap.coords.Point(s_endpoint1[1], s_endpoint1[0])
|
||||||
endpoint2 = coords.Point(s_endpoint2[1], s_endpoint2[0])
|
endpoint2 = ocitysmap.coords.Point(s_endpoint2[1], s_endpoint2[0])
|
||||||
current_category.items.append(commons.IndexItem(street_name,
|
current_category.items.append(commons.IndexItem(street_name,
|
||||||
endpoint1,
|
endpoint1,
|
||||||
endpoint2,
|
endpoint2,
|
||||||
|
@ -368,8 +368,8 @@ order by amenity_name""" \
|
||||||
repr(amenity_name)))
|
repr(amenity_name)))
|
||||||
continue
|
continue
|
||||||
## raise
|
## raise
|
||||||
endpoint1 = coords.Point(s_endpoint1[1], s_endpoint1[0])
|
endpoint1 = ocitysmap.coords.Point(s_endpoint1[1], s_endpoint1[0])
|
||||||
endpoint2 = coords.Point(s_endpoint2[1], s_endpoint2[0])
|
endpoint2 = ocitysmap.coords.Point(s_endpoint2[1], s_endpoint2[0])
|
||||||
current_category.items.append(commons.IndexItem(amenity_name,
|
current_category.items.append(commons.IndexItem(amenity_name,
|
||||||
endpoint1,
|
endpoint1,
|
||||||
endpoint2,
|
endpoint2,
|
||||||
|
@ -443,8 +443,8 @@ order by village_name""" \
|
||||||
repr(village_name)))
|
repr(village_name)))
|
||||||
continue
|
continue
|
||||||
## raise
|
## raise
|
||||||
endpoint1 = coords.Point(s_endpoint1[1], s_endpoint1[0])
|
endpoint1 = ocitysmap.coords.Point(s_endpoint1[1], s_endpoint1[0])
|
||||||
endpoint2 = coords.Point(s_endpoint2[1], s_endpoint2[0])
|
endpoint2 = ocitysmap.coords.Point(s_endpoint2[1], s_endpoint2[0])
|
||||||
current_category.items.append(commons.IndexItem(village_name,
|
current_category.items.append(commons.IndexItem(village_name,
|
||||||
endpoint1,
|
endpoint1,
|
||||||
endpoint2,
|
endpoint2,
|
||||||
|
@ -456,9 +456,7 @@ order by village_name""" \
|
||||||
return [category for category in result if category.items]
|
return [category for category in result if category.items]
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import os
|
from ocitysmap import i18n
|
||||||
import psycopg2
|
|
||||||
from ocitysmap2 import i18n
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
@ -472,7 +470,7 @@ if __name__ == "__main__":
|
||||||
"..", "..", "locale"))
|
"..", "..", "locale"))
|
||||||
|
|
||||||
# Chevreuse
|
# Chevreuse
|
||||||
chevreuse_bbox = coords.BoundingBox(48.7097, 2.0333, 48.7048, 2.0462)
|
chevreuse_bbox = ocitysmap.coords.BoundingBox(48.7097, 2.0333, 48.7048, 2.0462)
|
||||||
limits_wkt = chevreuse_bbox.as_wkt()
|
limits_wkt = chevreuse_bbox.as_wkt()
|
||||||
|
|
||||||
# Paris envelope:
|
# Paris envelope:
|
|
@ -18,12 +18,13 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import cairo
|
import cairo
|
||||||
import ocitysmap2.layoutlib.commons as UTILS
|
import math
|
||||||
import pango
|
import pango
|
||||||
import pangocairo
|
import pangocairo
|
||||||
import math
|
|
||||||
import draw_utils
|
import draw_utils
|
||||||
from ocitysmap2.layoutlib.abstract_renderer import Renderer
|
import ocitysmap.layoutlib.commons as UTILS
|
||||||
|
from ocitysmap.layoutlib.abstract_renderer import Renderer
|
||||||
|
|
||||||
# FIXME: refactoring
|
# FIXME: refactoring
|
||||||
# We use the same 10mm as GRAYED_MARGIN_MM in the map multi-page renderer
|
# We use the same 10mm as GRAYED_MARGIN_MM in the map multi-page renderer
|
||||||
|
@ -223,6 +224,7 @@ class MultiPageStreetIndexRenderer:
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
import commons
|
import commons
|
||||||
import coords
|
import coords
|
||||||
|
|
|
@ -29,7 +29,7 @@ import pango
|
||||||
import pangocairo
|
import pangocairo
|
||||||
|
|
||||||
import commons
|
import commons
|
||||||
import ocitysmap2.layoutlib.commons as UTILS
|
import ocitysmap.layoutlib.commons as UTILS
|
||||||
|
|
||||||
LOG = logging.getLogger('ocitysmap')
|
LOG = logging.getLogger('ocitysmap')
|
||||||
|
|
||||||
|
@ -495,7 +495,6 @@ if __name__ == '__main__':
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from ocitysmap2 import coords
|
|
||||||
import commons
|
import commons
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
@ -505,7 +504,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
random.seed(42)
|
random.seed(42)
|
||||||
|
|
||||||
bbox = coords.BoundingBox(48.8162, 2.3417, 48.8063, 2.3699)
|
bbox = ocitysmap.coords.BoundingBox(48.8162, 2.3417, 48.8063, 2.3699)
|
||||||
|
|
||||||
surface = cairo.PDFSurface('/tmp/myindex_render.pdf', width, height)
|
surface = cairo.PDFSurface('/tmp/myindex_render.pdf', width, height)
|
||||||
|
|
|
@ -23,28 +23,27 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import math
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import cairo
|
import cairo
|
||||||
|
import logging
|
||||||
import mapnik
|
import mapnik
|
||||||
assert mapnik.mapnik_version >= 200100, \
|
assert mapnik.mapnik_version >= 200100, \
|
||||||
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
||||||
"for more details." % mapnik.mapnik_version_string()
|
"for more details." % mapnik.mapnik_version_string()
|
||||||
|
import math
|
||||||
import pango
|
import pango
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from ocitysmap2.maplib.map_canvas import MapCanvas
|
|
||||||
from ocitysmap2.maplib.grid import Grid
|
|
||||||
import commons
|
|
||||||
from ocitysmap2 import maplib
|
|
||||||
from ocitysmap2 import draw_utils
|
|
||||||
import shapely.wkt
|
import shapely.wkt
|
||||||
|
import sys
|
||||||
|
|
||||||
import logging
|
import commons
|
||||||
|
from ocitysmap.maplib.map_canvas import MapCanvas
|
||||||
|
from ocitysmap.maplib.grid import Grid
|
||||||
|
from ocitysmap import draw_utils, maplib
|
||||||
|
|
||||||
LOG = logging.getLogger('ocitysmap')
|
LOG = logging.getLogger('ocitysmap')
|
||||||
|
|
||||||
|
|
||||||
class Renderer:
|
class Renderer:
|
||||||
"""
|
"""
|
||||||
The job of an OCitySMap layout renderer is to lay out the resulting map and
|
The job of an OCitySMap layout renderer is to lay out the resulting map and
|
||||||
|
@ -102,7 +101,7 @@ class Renderer:
|
||||||
os.path.dirname(__file__), '..', '..', 'images', 'osm-logo.png'))
|
os.path.dirname(__file__), '..', '..', 'images', 'osm-logo.png'))
|
||||||
if not os.path.exists(logo_path):
|
if not os.path.exists(logo_path):
|
||||||
logo_path = os.path.join(
|
logo_path = os.path.join(
|
||||||
sys.exec_prefix, 'share', 'images', 'ocitysmap2',
|
sys.exec_prefix, 'share', 'images', 'ocitysmap',
|
||||||
'osm-logo.png')
|
'osm-logo.png')
|
||||||
|
|
||||||
try:
|
try:
|
|
@ -19,42 +19,38 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
|
||||||
import logging
|
|
||||||
import tempfile
|
|
||||||
import math
|
|
||||||
import sys
|
|
||||||
import cairo
|
import cairo
|
||||||
|
import datetime
|
||||||
|
from itertools import groupby
|
||||||
|
import locale
|
||||||
|
import logging
|
||||||
import mapnik
|
import mapnik
|
||||||
assert mapnik.mapnik_version >= 200100, \
|
assert mapnik.mapnik_version >= 200100, \
|
||||||
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
||||||
"for more details." % mapnik.mapnik_version_string()
|
"for more details." % mapnik.mapnik_version_string()
|
||||||
import coords
|
import math
|
||||||
import locale
|
import os
|
||||||
import pangocairo
|
import pangocairo
|
||||||
import pango
|
import pango
|
||||||
import datetime
|
import shapely.wkt
|
||||||
|
import sys
|
||||||
from itertools import groupby
|
import tempfile
|
||||||
|
|
||||||
|
import ocitysmap
|
||||||
|
import coords
|
||||||
|
import commons
|
||||||
from abstract_renderer import Renderer
|
from abstract_renderer import Renderer
|
||||||
|
from indexlib.commons import IndexCategory
|
||||||
from ocitysmap2.maplib.map_canvas import MapCanvas
|
|
||||||
from ocitysmap2.maplib.grid import Grid
|
|
||||||
from ocitysmap2.maplib.overview_grid import OverviewGrid
|
|
||||||
from indexlib.indexer import StreetIndex
|
from indexlib.indexer import StreetIndex
|
||||||
from indexlib.multi_page_renderer import MultiPageStreetIndexRenderer
|
from indexlib.multi_page_renderer import MultiPageStreetIndexRenderer
|
||||||
|
from ocitysmap import draw_utils, maplib
|
||||||
import ocitysmap2
|
from ocitysmap.maplib.map_canvas import MapCanvas
|
||||||
import commons
|
from ocitysmap.maplib.grid import Grid
|
||||||
import shapely.wkt
|
from ocitysmap.maplib.overview_grid import OverviewGrid
|
||||||
from ocitysmap2 import maplib
|
|
||||||
from ocitysmap2 import draw_utils
|
|
||||||
|
|
||||||
from indexlib.commons import IndexCategory
|
|
||||||
|
|
||||||
LOG = logging.getLogger('ocitysmap')
|
LOG = logging.getLogger('ocitysmap')
|
||||||
|
|
||||||
|
|
||||||
class MultiPageRenderer(Renderer):
|
class MultiPageRenderer(Renderer):
|
||||||
"""
|
"""
|
||||||
This Renderer creates a multi-pages map, with all the classic overlayed
|
This Renderer creates a multi-pages map, with all the classic overlayed
|
||||||
|
@ -736,7 +732,7 @@ class MultiPageRenderer(Renderer):
|
||||||
index_position=None, hsplit=1, vsplit=1):
|
index_position=None, hsplit=1, vsplit=1):
|
||||||
valid_sizes = []
|
valid_sizes = []
|
||||||
acceptable_formats = [ 'A5', 'A4', 'US letter' ]
|
acceptable_formats = [ 'A5', 'A4', 'US letter' ]
|
||||||
for sz in ocitysmap2.layoutlib.PAPER_SIZES:
|
for sz in ocitysmap.layoutlib.PAPER_SIZES:
|
||||||
# Skip unsupported paper formats
|
# Skip unsupported paper formats
|
||||||
if sz[0] not in acceptable_formats:
|
if sz[0] not in acceptable_formats:
|
||||||
continue
|
continue
|
|
@ -22,24 +22,22 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import math
|
|
||||||
import datetime
|
|
||||||
import cairo
|
import cairo
|
||||||
|
import datetime
|
||||||
import locale
|
import locale
|
||||||
|
import logging
|
||||||
import mapnik
|
import mapnik
|
||||||
assert mapnik.mapnik_version >= 200100, \
|
assert mapnik.mapnik_version >= 200100, \
|
||||||
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
||||||
"for more details." % mapnik.mapnik_version_string()
|
"for more details." % mapnik.mapnik_version_string()
|
||||||
|
import math
|
||||||
import pango
|
import pango
|
||||||
import pangocairo
|
import pangocairo
|
||||||
|
|
||||||
import commons
|
import commons
|
||||||
import ocitysmap2
|
import ocitysmap
|
||||||
from abstract_renderer import Renderer
|
from abstract_renderer import Renderer
|
||||||
from ocitysmap2.indexlib.renderer import StreetIndexRenderer
|
from ocitysmap.indexlib.renderer import StreetIndexRenderer
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from indexlib.indexer import StreetIndex
|
from indexlib.indexer import StreetIndex
|
||||||
from indexlib.commons import IndexDoesNotFitError, IndexEmptyError
|
from indexlib.commons import IndexDoesNotFitError, IndexEmptyError
|
||||||
import draw_utils
|
import draw_utils
|
||||||
|
@ -510,7 +508,7 @@ class SinglePageRenderer(Renderer):
|
||||||
# Test both portrait and landscape orientations when checking for paper
|
# Test both portrait and landscape orientations when checking for paper
|
||||||
# sizes.
|
# sizes.
|
||||||
valid_sizes = []
|
valid_sizes = []
|
||||||
for name, w, h in ocitysmap2.layoutlib.PAPER_SIZES:
|
for name, w, h in ocitysmap.layoutlib.PAPER_SIZES:
|
||||||
portrait_ok = paper_width_mm <= w and paper_height_mm <= h
|
portrait_ok = paper_width_mm <= w and paper_height_mm <= h
|
||||||
landscape_ok = paper_width_mm <= h and paper_height_mm <= w
|
landscape_ok = paper_width_mm <= h and paper_height_mm <= w
|
||||||
|
|
||||||
|
@ -638,7 +636,7 @@ class SinglePageRendererIndexBottom(SinglePageRenderer):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import renderers
|
import renderers
|
||||||
import coords
|
import coords
|
||||||
from ocitysmap2 import i18n
|
from ocitysmap import i18n
|
||||||
|
|
||||||
# Hack to fake gettext
|
# Hack to fake gettext
|
||||||
try:
|
try:
|
|
@ -160,8 +160,8 @@ class Grid:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from ocitysmap2 import coords
|
import ocitysmap
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
grid = Grid(coords.BoundingBox(44.4883, -1.0901, 44.4778, -1.0637))
|
grid = Grid(ocitysmap.coords.BoundingBox(44.4883, -1.0901, 44.4778, -1.0637))
|
||||||
shape = grid.generate_shape_file('/tmp/mygrid.shp')
|
shape = grid.generate_shape_file('/tmp/mygrid.shp')
|
|
@ -34,12 +34,12 @@ assert mapnik.mapnik_version >= 200100, \
|
||||||
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
"Mapnik module version %s is too old, see ocitysmap's INSTALL " \
|
||||||
"for more details." % mapnik.mapnik_version_string()
|
"for more details." % mapnik.mapnik_version_string()
|
||||||
|
|
||||||
|
import math
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ocitysmap2 import coords
|
import ocitysmap
|
||||||
from layoutlib.commons import convert_pt_to_dots
|
from layoutlib.commons import convert_pt_to_dots
|
||||||
import shapes
|
import shapes
|
||||||
import math
|
|
||||||
|
|
||||||
l = logging.getLogger('ocitysmap')
|
l = logging.getLogger('ocitysmap')
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ class MapCanvas:
|
||||||
bounding box."""
|
bounding box."""
|
||||||
c0 = self._proj.inverse(mapnik.Coord(envelope.minx, envelope.miny))
|
c0 = self._proj.inverse(mapnik.Coord(envelope.minx, envelope.miny))
|
||||||
c1 = self._proj.inverse(mapnik.Coord(envelope.maxx, envelope.maxy))
|
c1 = self._proj.inverse(mapnik.Coord(envelope.maxx, envelope.maxy))
|
||||||
return coords.BoundingBox(c0.y, c0.x, c1.y, c1.x)
|
return ocitysmap.coords.BoundingBox(c0.y, c0.x, c1.y, c1.x)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
@ -208,7 +208,7 @@ if __name__ == '__main__':
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.path = '/home/sam/src/python/maposmatic/mapnik-osm/osm.xml'
|
self.path = '/home/sam/src/python/maposmatic/mapnik-osm/osm.xml'
|
||||||
|
|
||||||
bbox = coords.BoundingBox(48.7148, 2.0155, 48.6950, 2.0670)
|
bbox = ocitysmap.coords.BoundingBox(48.7148, 2.0155, 48.6950, 2.0670)
|
||||||
canvas = MapCanvas(StylesheetMock(), bbox, 297.0/210)
|
canvas = MapCanvas(StylesheetMock(), bbox, 297.0/210)
|
||||||
new_bbox = canvas.get_actual_bounding_box()
|
new_bbox = canvas.get_actual_bounding_box()
|
||||||
|
|
|
@ -22,14 +22,15 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
__version__ = '0.1'
|
__version__ = '0.22'
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
import sys, os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import ocitysmap2
|
import ocitysmap
|
||||||
import ocitysmap2.layoutlib.renderers
|
import ocitysmap.layoutlib.renderers
|
||||||
from coords import BoundingBox
|
from coords import BoundingBox
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -38,13 +39,13 @@ def main():
|
||||||
# Paper sizes, sorted in increasing widths
|
# Paper sizes, sorted in increasing widths
|
||||||
KNOWN_PAPER_SIZE_NAMES = \
|
KNOWN_PAPER_SIZE_NAMES = \
|
||||||
map(lambda p: p[0],
|
map(lambda p: p[0],
|
||||||
sorted(ocitysmap2.layoutlib.PAPER_SIZES,
|
sorted(ocitysmap.layoutlib.PAPER_SIZES,
|
||||||
key=lambda p: p[1]))
|
key=lambda p: p[1]))
|
||||||
|
|
||||||
# Known renderer names
|
# Known renderer names
|
||||||
KNOWN_RENDERERS_NAMES = \
|
KNOWN_RENDERERS_NAMES = \
|
||||||
map(lambda r: "%s (%s)" % (r.name, r.description),
|
map(lambda r: "%s (%s)" % (r.name, r.description),
|
||||||
ocitysmap2.layoutlib.renderers.get_renderers())
|
ocitysmap.layoutlib.renderers.get_renderers())
|
||||||
|
|
||||||
# Known paper orientations
|
# Known paper orientations
|
||||||
KNOWN_PAPER_ORIENTATIONS = ['portrait', 'landscape']
|
KNOWN_PAPER_ORIENTATIONS = ['portrait', 'landscape']
|
||||||
|
@ -53,46 +54,49 @@ def main():
|
||||||
parser = optparse.OptionParser(usage=usage,
|
parser = optparse.OptionParser(usage=usage,
|
||||||
version='%%prog %s' % __version__)
|
version='%%prog %s' % __version__)
|
||||||
parser.add_option('-C', '--config', dest='config_file', metavar='FILE',
|
parser.add_option('-C', '--config', dest='config_file', metavar='FILE',
|
||||||
help='Specify the location of the config file.')
|
help='specify the location of the config file.')
|
||||||
parser.add_option('-p', '--prefix', dest='output_prefix', metavar='PREFIX',
|
parser.add_option('-p', '--prefix', dest='output_prefix', metavar='PREFIX',
|
||||||
help='Specify the prefix of generated files. '
|
help='set a prefix to the generated file names. '
|
||||||
'Defaults to "citymap".',
|
'Defaults to "citymap".',
|
||||||
default='citymap')
|
default='citymap')
|
||||||
parser.add_option('-f', '--format', dest='output_formats', metavar='FMT',
|
parser.add_option('-f', '--format', dest='output_formats', metavar='FMT',
|
||||||
help='Specify the output formats. Supported file '
|
help='specify the output formats. Supported file '
|
||||||
'formats: svg, svgz, pdf, ps, ps.gz, png, and csv. '
|
'formats: svg, svgz, pdf, ps, ps.gz, png, and csv. '
|
||||||
'Defaults to PDF. May be specified multiple times.',
|
'Defaults to PDF. May be specified multiple times.',
|
||||||
action='append')
|
action='append')
|
||||||
parser.add_option('-t', '--title', dest='output_title', metavar='TITLE',
|
parser.add_option('-t', '--title', dest='output_title', metavar='TITLE',
|
||||||
help='Specify the title displayed in the output files.',
|
help='specify the title displayed in the output files.',
|
||||||
default="My Map")
|
default="My Map")
|
||||||
parser.add_option('--osmid', dest='osmid', metavar='OSMID',
|
parser.add_option('--osmid', dest='osmid', metavar='OSMID',
|
||||||
help='OSM id representing the polygon of the city '
|
help='OSM ID representing the polygon of the city '
|
||||||
'to render.', type="int"),
|
'to render.', type="int"),
|
||||||
parser.add_option('-b', '--bounding-box', dest='bbox', nargs=2,
|
parser.add_option('-b', '--bounding-box', dest='bbox', nargs=2,
|
||||||
metavar='LAT1,LON1 LAT2,LON2',
|
metavar='LAT1,LON1 LAT2,LON2',
|
||||||
help='Bounding box (EPSG: 4326).')
|
help='bounding box (EPSG: 4326).')
|
||||||
parser.add_option('-L', '--language', dest='language',
|
parser.add_option('-L', '--language', dest='language',
|
||||||
metavar='LANGUAGE_CODE',
|
metavar='LANGUAGE_CODE',
|
||||||
help='Language to use when generating the index'
|
help='language to use when generating the index '
|
||||||
' (default=fr_FR.UTF-8).',
|
'(default=fr_FR.UTF-8). The map language is '
|
||||||
|
'driven by the system\' locale setting.',
|
||||||
default='fr_FR.UTF-8')
|
default='fr_FR.UTF-8')
|
||||||
parser.add_option('-s', '--stylesheet', dest='stylesheet',
|
parser.add_option('-s', '--stylesheet', dest='stylesheet',
|
||||||
metavar='NAME',
|
metavar='NAME',
|
||||||
help="Name of the stylesheet to use. Defaults to the "
|
help='specify which stylesheet to use. Defaults to the '
|
||||||
"first specified in the config file.")
|
'first specified in the configuration file.')
|
||||||
parser.add_option('-l', '--layout', dest='layout',
|
parser.add_option('-l', '--layout', dest='layout',
|
||||||
metavar='NAME',
|
metavar='NAME',
|
||||||
default=KNOWN_RENDERERS_NAMES[0].split()[0],
|
default=KNOWN_RENDERERS_NAMES[0].split()[0],
|
||||||
help= ("Name of the layout to use, among %s. Default: %s."
|
help=('specify which layout to use. Available layouts '
|
||||||
% (', '.join(KNOWN_RENDERERS_NAMES),
|
'are: %s. Defaults to %s.' %
|
||||||
KNOWN_RENDERERS_NAMES[0].split()[0])))
|
(', '.join(KNOWN_RENDERERS_NAMES),
|
||||||
|
KNOWN_RENDERERS_NAMES[0].split()[0])))
|
||||||
parser.add_option('--paper-format', metavar='FMT',
|
parser.add_option('--paper-format', metavar='FMT',
|
||||||
help='Either "default", or one of %s.'\
|
help='set the output paper format. Either "default", '
|
||||||
% ', '.join(KNOWN_PAPER_SIZE_NAMES),
|
'or one of %s.' % ', '.join(KNOWN_PAPER_SIZE_NAMES),
|
||||||
default='default')
|
default='default')
|
||||||
parser.add_option('--orientation', metavar='ORIENTATION',
|
parser.add_option('--orientation', metavar='ORIENTATION',
|
||||||
help='Either "portrait" or "landscape".',
|
help='set the output paper orientation. Either '
|
||||||
|
'"portrait" or "landscape". Defaults to portrait.',
|
||||||
default='portrait')
|
default='portrait')
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
@ -115,9 +119,8 @@ def main():
|
||||||
"or --osmid are exclusive")
|
"or --osmid are exclusive")
|
||||||
|
|
||||||
# Parse config file and instanciate main object
|
# Parse config file and instanciate main object
|
||||||
mapper = ocitysmap2.OCitySMap([options.config_file
|
mapper = ocitysmap.OCitySMap(
|
||||||
or os.path.join(os.environ["HOME"],
|
[options.config_file or os.path.join(os.environ["HOME"], '.ocitysmap.conf')])
|
||||||
'.ocitysmap.conf')])
|
|
||||||
|
|
||||||
# Parse bounding box arguments when given
|
# Parse bounding box arguments when given
|
||||||
bbox = None
|
bbox = None
|
||||||
|
@ -150,21 +153,20 @@ def main():
|
||||||
stylesheet = mapper.get_stylesheet_by_name(options.stylesheet)
|
stylesheet = mapper.get_stylesheet_by_name(options.stylesheet)
|
||||||
except LookupError, ex:
|
except LookupError, ex:
|
||||||
parser.error("%s. Available stylesheets: %s."
|
parser.error("%s. Available stylesheets: %s."
|
||||||
% (ex, ', '.join(map(lambda s: "%s (%s)"
|
% (ex, ', '.join(map(lambda s: s.name,
|
||||||
% (s.name, s.description),
|
mapper.STYLESHEET_REGISTRY))))
|
||||||
mapper.STYLESHEET_REGISTRY))))
|
|
||||||
|
|
||||||
# Parse rendering layout
|
# Parse rendering layout
|
||||||
if options.layout is None:
|
if options.layout is None:
|
||||||
cls_renderer = ocitysmap2.layoutlib.renderers.get_renderers()[0]
|
cls_renderer = ocitysmap.layoutlib.renderers.get_renderers()[0]
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
cls_renderer = ocitysmap2.layoutlib.renderers.get_renderer_class_by_name(options.layout)
|
cls_renderer = ocitysmap.layoutlib.renderers.get_renderer_class_by_name(options.layout)
|
||||||
except LookupError, ex:
|
except LookupError, ex:
|
||||||
parser.error("%s\nAvailable layouts: %s."
|
parser.error("%s\nAvailable layouts: %s."
|
||||||
% (ex, ', '.join(map(lambda lo: "%s (%s)"
|
% (ex, ', '.join(map(lambda lo: "%s (%s)"
|
||||||
% (lo.name, lo.description),
|
% (lo.name, lo.description),
|
||||||
ocitysmap2.layoutlib.renderers.get_renderers()))))
|
ocitysmap.layoutlib.renderers.get_renderers()))))
|
||||||
|
|
||||||
# Output file formats
|
# Output file formats
|
||||||
if not options.output_formats:
|
if not options.output_formats:
|
||||||
|
@ -218,7 +220,7 @@ def main():
|
||||||
parser.error("Requested paper orientation %s not compatible with this rendering at this paper size." % options.orientation)
|
parser.error("Requested paper orientation %s not compatible with this rendering at this paper size." % options.orientation)
|
||||||
|
|
||||||
# Prepare the rendering config
|
# Prepare the rendering config
|
||||||
rc = ocitysmap2.RenderingConfiguration()
|
rc = ocitysmap.RenderingConfiguration()
|
||||||
rc.title = options.output_title
|
rc.title = options.output_title
|
||||||
rc.osmid = options.osmid or None # Force to None if absent
|
rc.osmid = options.osmid or None # Force to None if absent
|
||||||
rc.bounding_box = bbox
|
rc.bounding_box = bbox
|
16
setup.py
16
setup.py
|
@ -39,11 +39,13 @@ designed to be printed.
|
||||||
license="GPL",
|
license="GPL",
|
||||||
maintainer="The Hackfest2009 team",
|
maintainer="The Hackfest2009 team",
|
||||||
maintainer_email="staff@maposmatic.org",
|
maintainer_email="staff@maposmatic.org",
|
||||||
packages = ['ocitysmap2',
|
packages = ['ocitysmap',
|
||||||
'ocitysmap2.maplib',
|
'ocitysmap.maplib',
|
||||||
'ocitysmap2.indexlib',
|
'ocitysmap.indexlib',
|
||||||
'ocitysmap2.layoutlib' ],
|
'ocitysmap.layoutlib' ],
|
||||||
scripts = ['ocitysmap2-render' ],
|
scripts = ['render.py' ],
|
||||||
data_files = [ ('share/images/ocitysmap2',
|
data_files = [
|
||||||
['images/osm-logo.png', 'images/osm-logo.svg']) ]
|
('share/images/ocitysmap', ['images/osm-logo.png',
|
||||||
|
'images/osm-logo.svg'])
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -21,47 +21,47 @@ TESTS=(
|
||||||
TESTID=0
|
TESTID=0
|
||||||
|
|
||||||
for tst in ${TESTS[@]} ; do
|
for tst in ${TESTS[@]} ; do
|
||||||
type=$(echo $tst | cut -f1 -d':')
|
type=$(echo $tst | cut -f1 -d':')
|
||||||
title=$(echo $tst | cut -f2 -d':')
|
title=$(echo $tst | cut -f2 -d':')
|
||||||
ref=$(echo $tst | cut -f3 -d':')
|
ref=$(echo $tst | cut -f3 -d':')
|
||||||
renderer=$(echo $tst | cut -f4 -d':')
|
renderer=$(echo $tst | cut -f4 -d':')
|
||||||
paper_format=$(echo $tst | cut -f5 -d':')
|
paper_format=$(echo $tst | cut -f5 -d':')
|
||||||
paper_orientation=$(echo $tst | cut -f6 -d':')
|
paper_orientation=$(echo $tst | cut -f6 -d':')
|
||||||
|
|
||||||
if [ $type == "osmid" ] ; then
|
if [ $type == "osmid" ] ; then
|
||||||
area_opt="--osmid=$ref"
|
area_opt="--osmid=$ref"
|
||||||
else
|
else
|
||||||
bbox_part1=$(echo $ref|cut -f1 -d'-')
|
bbox_part1=$(echo $ref|cut -f1 -d'-')
|
||||||
bbox_part2=$(echo $ref|cut -f2 -d'-')
|
bbox_part2=$(echo $ref|cut -f2 -d'-')
|
||||||
area_opt="-b ${bbox_part1} ${bbox_part2}"
|
area_opt="-b ${bbox_part1} ${bbox_part2}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $renderer == "multi_page" ] ; then
|
if [ $renderer == "multi_page" ] ; then
|
||||||
output_formats="-f pdf"
|
output_formats="-f pdf"
|
||||||
else
|
else
|
||||||
output_formats="-f png -f pdf -f svgz"
|
output_formats="-f png -f pdf -f svgz"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "\e[31m>>> Starting test with\n area='%s'\n renderer='%s'\n formats='%s'\n paper='%s'\n orientation='%s'\n title='%s'\n\n\e[m" \
|
printf "\e[31m>>> Starting test with\n area='%s'\n renderer='%s'\n formats='%s'\n paper='%s'\n orientation='%s'\n title='%s'\n\n\e[m" \
|
||||||
"$area_opt" \
|
"$area_opt" \
|
||||||
"$renderer" \
|
"$renderer" \
|
||||||
"$output_formats" \
|
"$output_formats" \
|
||||||
"$paper_format" \
|
"$paper_format" \
|
||||||
"$paper_orientation" \
|
"$paper_orientation" \
|
||||||
"$title"
|
"$title"
|
||||||
|
|
||||||
./ocitysmap2-render \
|
./render.py \
|
||||||
$output_formats \
|
$output_formats \
|
||||||
-l $renderer \
|
-l $renderer \
|
||||||
$area_opt \
|
$area_opt \
|
||||||
-p test_$TESTID \
|
-p test_$TESTID \
|
||||||
-t "$title" \
|
-t "$title" \
|
||||||
--paper-format=$paper_format \
|
--paper-format=$paper_format \
|
||||||
--orientation=$paper_orientation
|
--orientation=$paper_orientation
|
||||||
|
|
||||||
if [ $? -ne 0 ] ; then
|
if [ $? -ne 0 ] ; then
|
||||||
echo "==== ERROR, ABORTING"
|
echo "==== ERROR, ABORTING"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
TESTID=$((TESTID+1))
|
TESTID=$((TESTID+1))
|
||||||
done
|
done
|
||||||
|
|
Ładowanie…
Reference in New Issue