Zh-hans:Maperitive

From OpenStreetMap Wiki
Jump to navigation Jump to search
本页面由 AI 从英文页面翻译而来,内容需要人工复核。
View on OSM Apps Catalog  
Maperitive
v · d 
作者: Igor Brejc
执照: Proprietary (免费)
平台: Windows、​​ Linux和​ macOS
Status幫忙將此翻譯成簡體中文!: Unmaintained
版本: 2.4.3 (2018-02-27[1])
语言:
英语
网站: http://maperitive.net
编程语言: C#

Desktop based

Features
Feature Value
Map Display
?
Routing
?
Navigating
?
Tracking
?
Monitoring
?
Editing
?
Rendering
?
Accessibility
?
German power grid as rendered in Maperitive.

Maperitive 是一款桌面应用,可利用 OSM 及其他数据源实时渲染地图。它是 Kosmos 的继任者。

完整文档(最后更新于 2016 年)见 http://maperitive.net/docs/。这里的说明只是供您在完整文档撰写期间入门使用,来自早期采用者的“发现”和作者有帮助的邮件。

您可以从 http://maperitive.net/download/Maperitive-latest.zip 下载 Maperitive 最新版本(需要 .NET Framework v4.0)。请注意它仍处于开发的 beta 阶段,目前只有简单的图形界面,并通过命令控制台来控制。使用命令行时请注意 Linux 下用 / 与 Windows 下用 \ 的差别。

安装

Windows

从 http://maperitive.net/download/Maperitive-latest.zip 下载最新版 Maperitive zip 文件,解压到您选择的目录中(去掉版本号可能比较明智,因为更新会放到同一位置)。

运行它只需双击 maperitive.exe(在桌面上创建快捷方式可能会有所帮助)

Ubuntu 10.04 - 12.10

从 http://maperitive.net/download/Maperitive-latest.zip 下载最新版 Maperitive zip 文件,解压到您选择的目录中。Maperitive 还需要若干依赖项。可通过打开终端窗口并运行以下命令来安装:

sudo apt-get install libmono-winforms2.0-cil mono-devel

下载并安装完成后,切换到您解压 Maperitive 的目录,把 Maperitive.sh 文件标记为可执行并运行它。这可以通过右键点击该文件并将属性改为“允许作为程序执行”来完成,或者在终端中运行以下命令:

chmod +x ./Maperitive.sh
./Maperitive.sh

Ubuntu 10.04

由于 Maperitive 的规则文件使用专有的文件扩展名(.mrules),使用 edit-rules 编辑它们可能会失败。要解决此问题,请创建相应的自定义 MIME 类型和 mailcap 条目。以下命令为当前用户定义 mrules 文件的 MIME 类型,并将 gedit 设为编辑它们的默认应用:

echo "text/vnd-maperitive-rules  mrules" >> ~/.mime.types
echo "text/vnd-maperitive-rules; gedit '%s'; description=\"Maperitive rules file\"; test=test -n \"\$DISPLAY\"" >> ~/.mailcap

Fedora 14

从 http://maperitive.net/download/Maperitive-latest.zip 下载最新版 Maperitive zip 文件,解压到您选择的目录中(去掉版本号可能比较明智,因为更新会放到同一位置)。

以 root 身份执行

yum install mono-winforms

然后切换到您解压 Maperitive 的目录,并用以下命令使其可执行

chmod +x ./Maperitive.sh

要启动 Maperitive,请输入

./Maperitive.sh

修复 Fedora 29 中的 mono System.ConsoleDriver 异常

如果 Maperitive 启动时无法加载地图,请像这样编辑您的 Maperitive.sh 文件:

#!/bin/sh
export TERM=xterm
mono --desktop Maperitive.exe "$@"

Mac OS X

下载并安装最新版 Mono。

Mac 上必须安装 X11。可从 XQuartz 下载。

下载 http://maperitive.net/download/Maperitive-latest.zip,解压并把整个目录移动到应用程序目录(或任何其他位置)。

要启动 Maperitive,请打开终端并切换到 Maperitive 目录:

cd /Applications/Maperitive

启动 Maperitive:

mono --arch=32 Maperitive.exe

如果您使用的 Mono 版本早于 v5.2,可以省略 --arch 开关[2],因为这些版本默认为 32 位运行。

Maperitive 的启动可能需要一点时间,请稍等。

获取一些数据

您需要一个 OSM 数据文件。获取方式有多种:

  • 在 JOSM 中下载一个区域,然后用“文件 > 另存为”保存
  • 从 Geofabrik 挑选 bz2 文件

建议不要使用非常大的区域,因为 Maperitive 会把所有数据加载到内存中。用 Osmosis 或 Osmconvert 裁掉您不需要的数据。

为工作文件建立一个目录是好主意,例如包含 data、rules、scripts 和 outputs 子目录。

后面的示例假定您的数据位于 c:\users\igor\documents\osm\maperitive\data\test.osm

基本说明

要输入命令,请点击屏幕底部的灰色条(或直接按 ↵ Enter)——该条会变成黄色。有些命令也可在菜单中找到。请注意 Maperitive 只要求输入足以唯一识别某条命令的字母数。它会随输入自动补全。

默认情况下,背景显示 OSM“标准”瓦片(如果您已连接互联网)。您需要移动到与数据匹配的位置。例如,这会把您带到伦敦市中心:

move-pos x=-0.11 y=51.52

您可以在 Mapnik 背景之上渲染数据,也可以使用空白页面:

clear-map

假设您的数据在单独目录中,把它设为默认目录会方便些,例如

change-directory c:\users\igor\documents\osm\maperitive\

要加载数据,请执行命令:

load-source data\test.osm

地图将使用默认规则(位于随 Maperitive 附带的 rules\default.txt 文件中)加载和渲染。这些规则与普通 Mapnik 渲染类似。为永久保存这一刻:

export-bitmap zoom=15 file=outputs\test.png width=3000 height=3000 scale=3

恭喜。您已经是一名渲染者了。

更改渲染规则

要更改渲染规则,请打开当前规则,并打算在工作目录中保存一份副本(最好立即“文件 > 另存为”到 rules\test.mrules):

edit-rules

编辑时,您需要保持缩进。可以试着更改一些颜色(大多数常见颜色可以用单词输入)。当您做出并保存了一些更改后:

use-ruleset location=rules\test.mrules as-alias=test
apply-ruleset

保存更改后,运行

reload-ruleset

以使用新规则再次渲染地图。Maperitive 会在几秒钟内显示新规则的效果。 要切换回默认规则,请使用别名:

use-ruleset alias=default
apply-ruleset

Maperitive 会记住您规则的位置,因此无需重新加载。如果重用某个别名,它会覆盖旧位置。

“wireframe”规则集是一个有用的规则集。它会渲染所有线条,无论其带有何种标签。该规则集是预定义的,别名为“wireframe”。您可以先用 use-ruleset alias=wireframe,再用 apply-ruleset 来使用它

用户修改或创建的规则示例可在本 Wiki 的 Category Maperitive/Rules 中找到,一些渲染示例见:Maperitive/SampleRenderings。

脚本

您可以把一组命令保存到一个简单的文本文件中(称为脚本)。例如

move-pos x=-0.11 y=51.52
clear-map
change-directory c:\users\igor\documents\osm\maperitive\
use-ruleset location=rules\test.txt as-alias=test
load-source data\test.osm
export-bitmap zoom=15 file=outputs\test.png width=3000 height=3000 scale=3

然后您可以一次运行所有这些命令:

run-script c:\users\igor\documents\osm\maperitive\scripts\myscript.txt

To save all that typing, you could put a change-directory command in the scripts\default.txt file that came with Maperitive (but be aware it might get overwritten by an update). Alternatively, create a Windows batch file (a text file with a .bat extension) in your working directory containing: maperitive.exe scripts\myscript.txt and create a shortcut to the batch file on your desktop. Within the shortcut's file properties, you need to set Start In to the location of maperitive.exe. You can also use the maperitive.ico icon (same place as maperitive.exe).

理解规则文件

规则文件的高层结构是:

features
        ...
        areas
                ...
        lines
                ...
        points
                ...
properties
        ...
rules
        target : feature1
                ...
        target : feature2
                ...

features 节告诉 Maperitive 您想使用什么数据。您可以定义一个只查看区域、线条或点的要素,也可以让它检查所有内容。

properties 节让您覆盖 Maperitive 的默认设置(例如它使用的字体)。

rules 节告诉 Maperitive 对符合所述条件的任何要素(数据集)绘制什么。通常您会先定义一些属性,然后用这些属性绘制某些内容。您可以根据进一步的测试在每条规则内更改渲染,这实际上使它非常灵活。

命令

完整命令列表可通过输入 help-commands 查看。它们滚动得非常快,窗口又很窄,因此在下面按 809 版(2010 年 3 月 28 日)列出。

命令 操作
add-web-map background=<draw the map in background (true/false)> intensity=<intensity of the web map (from 0 to 1)> provider=<name of the web map provider (mapnik, osmarender, osm cyclemap> adds a web map provider to the map
apply-ruleset [sourceindex] applies the active ruleset to the map
change-directory <directory> changes the current directory
check-updates checks for new updates in Maperitive software
clear-cache webmap=<clear cached web map tiles> clears the application cache
clear-command-history clears the command history
clear-map clears the map (removes all map sources)
clear-results clears the search results
dump-bounds dumps the map view bounds to the command log
dump-entrails dumps Mapertivie's entrails to the command log (for debugging purposes)
dump-pos dumps the current map position to the command log
exit closes the Maperitive application
export-bitmap aspect=<preserve aspect ratio> scale=<scale> zoom=<zoom level> file=<bitmap file name> width=<bitmap width> height=<bitmap height> exports the current map view to a bitmap file, also creates a worldfile
export-command-history <outputfilename> exports the command history to a text file
export-osm <filename> [sourceindex] exports the current map view to an OSM file (just the OSM data)
find <specificationtext> searches for map data using a query language
find-here <specificationtext> searches for map data using a query language but restricts the search to the visible map window
find-next moves to the next item in search results
find-prev moves to the previous item in search results
generate-contours [elevationinterval] generates relief contours for the current map view
get-info displays detailed information about the currently focused map object
help displays basic help information
help-commands displays a list of all Maperitive commands
help-keyboard displays a list of all Maperitive keyboard shortcuts
help-properties displays a list of all rendering rules properties in Maperitive
list-results dumps search results list in the command log
list-rulesets displays a list of all registered rulesets
list-sources displays a list of all map sources on the map
list-viewpoints
load-source <filename> loads a map source from a file (OSM, GPX or IBF file)
move-pos <x> <y> [zoom] moves the map to a new position
prompt sets the focus on the command prompt
remove-ruleset index=<ruleset index> alias=<ruleset alias> location=<ruleset location> removes (deregisters) a ruleset
remove-source [sourceindex] removes a specific map source from the map
run-script <scriptfilename> runs a Maperitive script from the specified file
save-map-script <scriptfilename> saves the current map as a Maperitive script
save-source <sourceindex> <destfilename> saves a specific map source to the specified file
send-feedback opens your mail client and prepares a mail message to Maperitive's author
use-ruleset index=<ruleset index> as-alias=<new alias> location=<ruleset location> alias=<ruleset alias> activates a specific ruleset
zoom <zoomfactor> sets the zoom level of the map view
zoom-all zooms to the extents of the map
zoom-bounds <minx> <miny> <maxx> <maxy> zooms to the specific map bounds
zoom-in zooms in
zoom-out zooms out
zoom-selection zooms to the currently focused element

键盘快捷键

The full list of Keyboard-Shortcuts can be seen by typing help-keyboard. They scroll past really quickly and the window is very narrow, so here they are listed as at version 1154 (April 2nd, 2011)

> help-keyboard
   F3 (global): find-next
   Shift+F3 (global): find-prev
   Ctrl+A (map): zoom-all
   Ctrl+Shift+C (global): generate-contours
   Ctrl+Shift+D (global): download-osm
   Ctrl+E (global): export-bitmap
   Ctrl+H (global): go-home
   Ctrl+M (global): focus-map
   Ctrl+N (global): clear-map
   Ctrl+Q (global): exit
   Ctrl+R (global): reload-ruleset
   + (map): zoom-in
   = (map): zoom-in
   - (map): zoom-out
   Left (map): move-screen-pos x=-0.1
   Right (map): move-screen-pos x=0.1
   Up (map): move-screen-pos y=-0.1
   Down (map): move-screen-pos y=0.1
   Ctrl+Enter (global): prompt

图标

Mapnik icons are included with Maperitive, but others are available (some of them may be subject to license, so at your own risk!) at:

Maperitive copies icons to the cache\images\ directory, and then simply refers to the filename. So once the rules have been used once, there is no need to be connected to the internet.

链接

闭源

Screenshot of the Firefox application viewing the page "maperitivenet/docs/FAQ.html#Where is the source code?". 3 questions & answers are visible. The first question is "Q: I would like to see the source code of Maperitive.". It has answer "A: You can't. Maperitive is not an open source application."
Mapertive is closed-source software and its author decided against open licensing (source).

Note that Maperitive is closed-source software. The original author (who abandoned the project in 2018) decided against a FOSS license.

Because the source code is not available, it is not possible for others to continue development on Maperitive.

操作指南

How to use Maperitive to work off line and display different options simply for the end user.

How to use Maperitive's find command.

Example for rulesets can be found under

Example for scripts can be found under

How to export vector contour data from Maperitive (for import into Inkscape)

参考资料