switch package org.mapsforge -> org.oscim
This commit is contained in:
42
src/org/oscim/theme/AnyMatcher.java
Normal file
42
src/org/oscim/theme/AnyMatcher.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
final class AnyMatcher implements AttributeMatcher {
|
||||
private static final AnyMatcher INSTANCE = new AnyMatcher();
|
||||
|
||||
static AnyMatcher getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor to prevent instantiation from other classes.
|
||||
*/
|
||||
private AnyMatcher() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCoveredBy(AttributeMatcher attributeMatcher) {
|
||||
return attributeMatcher == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Tag[] tags) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
23
src/org/oscim/theme/AttributeMatcher.java
Normal file
23
src/org/oscim/theme/AttributeMatcher.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
interface AttributeMatcher {
|
||||
boolean isCoveredBy(AttributeMatcher attributeMatcher);
|
||||
|
||||
boolean matches(Tag[] tags);
|
||||
}
|
||||
21
src/org/oscim/theme/Closed.java
Normal file
21
src/org/oscim/theme/Closed.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
final class Closed {
|
||||
public static final int ANY = 0;
|
||||
public static final int NO = 1;
|
||||
public static final int YES = 2;
|
||||
}
|
||||
21
src/org/oscim/theme/Element.java
Normal file
21
src/org/oscim/theme/Element.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
final class Element {
|
||||
public static final int ANY = 0;
|
||||
public static final int NODE = 1;
|
||||
public static final int WAY = 2;
|
||||
}
|
||||
108
src/org/oscim/theme/ExternalRenderTheme.java
Normal file
108
src/org/oscim/theme/ExternalRenderTheme.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
|
||||
|
||||
/**
|
||||
* An ExternalRenderTheme allows for customizing the rendering style of the map via an XML file.
|
||||
*/
|
||||
public class ExternalRenderTheme implements Theme {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final long mFileModificationDate;
|
||||
private transient int mHashCodeValue;
|
||||
private final String mRenderThemePath;
|
||||
|
||||
/**
|
||||
* @param renderThemePath
|
||||
* the path to the XML render theme file.
|
||||
* @throws FileNotFoundException
|
||||
* if the file does not exist or cannot be read.
|
||||
*/
|
||||
public ExternalRenderTheme(String renderThemePath) throws FileNotFoundException {
|
||||
File renderThemeFile = new File(renderThemePath);
|
||||
if (!renderThemeFile.exists()) {
|
||||
throw new FileNotFoundException("file does not exist: " + renderThemePath);
|
||||
} else if (!renderThemeFile.isFile()) {
|
||||
throw new FileNotFoundException("not a file: " + renderThemePath);
|
||||
} else if (!renderThemeFile.canRead()) {
|
||||
throw new FileNotFoundException("cannot read file: " + renderThemePath);
|
||||
}
|
||||
|
||||
mFileModificationDate = renderThemeFile.lastModified();
|
||||
if (mFileModificationDate == 0L) {
|
||||
throw new FileNotFoundException("cannot read last modification time");
|
||||
}
|
||||
mRenderThemePath = renderThemePath;
|
||||
calculateTransientValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
} else if (!(obj instanceof ExternalRenderTheme)) {
|
||||
return false;
|
||||
}
|
||||
ExternalRenderTheme other = (ExternalRenderTheme) obj;
|
||||
if (mFileModificationDate != other.mFileModificationDate) {
|
||||
return false;
|
||||
} else if (mRenderThemePath == null && other.mRenderThemePath != null) {
|
||||
return false;
|
||||
} else if (mRenderThemePath != null && !mRenderThemePath.equals(other.mRenderThemePath)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getRenderThemeAsStream() throws FileNotFoundException {
|
||||
return new FileInputStream(mRenderThemePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mHashCodeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hash code of this object.
|
||||
*/
|
||||
private int calculateHashCode() {
|
||||
int result = 1;
|
||||
result = 31 * result + (int) (mFileModificationDate ^ (mFileModificationDate >>> 32));
|
||||
result = 31 * result + ((mRenderThemePath == null) ? 0 : mRenderThemePath.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the values of some transient variables.
|
||||
*/
|
||||
private void calculateTransientValues() {
|
||||
mHashCodeValue = calculateHashCode();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||
objectInputStream.defaultReadObject();
|
||||
calculateTransientValues();
|
||||
}
|
||||
}
|
||||
112
src/org/oscim/theme/IRenderCallback.java
Normal file
112
src/org/oscim/theme/IRenderCallback.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.theme.renderinstruction.Area;
|
||||
import org.oscim.theme.renderinstruction.Caption;
|
||||
import org.oscim.theme.renderinstruction.Line;
|
||||
import org.oscim.theme.renderinstruction.PathText;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Paint;
|
||||
|
||||
/**
|
||||
* Callback methods for rendering areas, ways and points of interest (POIs).
|
||||
*/
|
||||
public interface IRenderCallback {
|
||||
/**
|
||||
* Renders an area with the given parameters.
|
||||
*
|
||||
* @param area
|
||||
* ...
|
||||
* @param level
|
||||
* ...
|
||||
*/
|
||||
void renderArea(Area area, int level);
|
||||
|
||||
/**
|
||||
* Renders an area caption with the given text.
|
||||
*
|
||||
* @param caption
|
||||
* the text to be rendered.
|
||||
*/
|
||||
void renderAreaCaption(Caption caption);
|
||||
|
||||
/**
|
||||
* Renders an area symbol with the given bitmap.
|
||||
*
|
||||
* @param symbol
|
||||
* the symbol to be rendered.
|
||||
*/
|
||||
void renderAreaSymbol(Bitmap symbol);
|
||||
|
||||
/**
|
||||
* Renders a point of interest caption with the given text.
|
||||
*
|
||||
* @param caption
|
||||
* the text to be rendered.
|
||||
*/
|
||||
void renderPointOfInterestCaption(Caption caption);
|
||||
|
||||
/**
|
||||
* Renders a point of interest circle with the given parameters.
|
||||
*
|
||||
* @param radius
|
||||
* the radius of the circle.
|
||||
* @param fill
|
||||
* the paint to be used for rendering the circle.
|
||||
* @param level
|
||||
* the drawing level on which the circle should be rendered.
|
||||
*/
|
||||
void renderPointOfInterestCircle(float radius, Paint fill, int level);
|
||||
|
||||
/**
|
||||
* Renders a point of interest symbol with the given bitmap.
|
||||
*
|
||||
* @param symbol
|
||||
* the symbol to be rendered.
|
||||
*/
|
||||
void renderPointOfInterestSymbol(Bitmap symbol);
|
||||
|
||||
/**
|
||||
* Renders a way with the given parameters.
|
||||
*
|
||||
* @param line
|
||||
* ...
|
||||
* @param level
|
||||
* ...
|
||||
*/
|
||||
void renderWay(Line line, int level);
|
||||
|
||||
/**
|
||||
* Renders a way with the given symbol along the way path.
|
||||
*
|
||||
* @param symbol
|
||||
* the symbol to be rendered.
|
||||
* @param alignCenter
|
||||
* true if the symbol should be centered, false otherwise.
|
||||
* @param repeat
|
||||
* true if the symbol should be repeated, false otherwise.
|
||||
*/
|
||||
void renderWaySymbol(Bitmap symbol, boolean alignCenter, boolean repeat);
|
||||
|
||||
/**
|
||||
* Renders a way with the given text along the way path.
|
||||
*
|
||||
* @param pathText
|
||||
* ...
|
||||
*/
|
||||
void renderWayText(PathText pathText);
|
||||
}
|
||||
43
src/org/oscim/theme/InternalRenderTheme.java
Normal file
43
src/org/oscim/theme/InternalRenderTheme.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
/**
|
||||
* Enumeration of all internal rendering themes.
|
||||
*/
|
||||
public enum InternalRenderTheme implements Theme {
|
||||
/**
|
||||
* A rendering theme similar to the OpenStreetMap Osmarender style.
|
||||
*
|
||||
* @see <a href="http://wiki.openstreetmap.org/wiki/Osmarender">Osmarender</a>
|
||||
*/
|
||||
OSMARENDER("/org/oscim/theme/osmarender/osmarender.xml"),
|
||||
|
||||
TRONRENDER("/org/oscim/theme/osmarender/tronrender.xml");
|
||||
|
||||
private final String mPath;
|
||||
|
||||
private InternalRenderTheme(String path) {
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getRenderThemeAsStream() {
|
||||
return InternalRenderTheme.class.getResourceAsStream(mPath);
|
||||
}
|
||||
}
|
||||
106
src/org/oscim/theme/MatchingCacheKey.java
Normal file
106
src/org/oscim/theme/MatchingCacheKey.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class MatchingCacheKey {
|
||||
int mHashCodeValue;
|
||||
Tag[] mTags;
|
||||
byte mZoomLevel;
|
||||
|
||||
MatchingCacheKey() {
|
||||
}
|
||||
|
||||
MatchingCacheKey(Tag[] tags, byte zoomLevel) {
|
||||
mTags = tags;
|
||||
mZoomLevel = zoomLevel;
|
||||
mHashCodeValue = calculateHashCode();
|
||||
}
|
||||
|
||||
MatchingCacheKey(MatchingCacheKey key) {
|
||||
mTags = key.mTags;
|
||||
mZoomLevel = key.mZoomLevel;
|
||||
mHashCodeValue = key.mHashCodeValue;
|
||||
}
|
||||
|
||||
void set(Tag[] tags, byte zoomLevel) {
|
||||
mTags = tags;
|
||||
mZoomLevel = zoomLevel;
|
||||
|
||||
int result = 7;
|
||||
|
||||
for (int i = 0, n = mTags.length; i < n; i++) {
|
||||
if (mTags[i] == null)
|
||||
break;
|
||||
result = 31 * result + mTags[i].hashCode();
|
||||
}
|
||||
result = 31 * result + mZoomLevel;
|
||||
|
||||
mHashCodeValue = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
// else if (!(obj instanceof MatchingCacheKey)) {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
MatchingCacheKey other = (MatchingCacheKey) obj;
|
||||
|
||||
if (mZoomLevel != other.mZoomLevel)
|
||||
return false;
|
||||
|
||||
if (mTags == null) {
|
||||
return (other.mTags == null);
|
||||
} else if (other.mTags == null)
|
||||
return false;
|
||||
|
||||
int length = mTags.length;
|
||||
if (length != other.mTags.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
if (mTags[i] != other.mTags[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mHashCodeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hash code of this object.
|
||||
*/
|
||||
private int calculateHashCode() {
|
||||
int result = 7;
|
||||
|
||||
for (int i = 0, n = mTags.length; i < n; i++) {
|
||||
if (mTags[i] == null) // FIXME
|
||||
break;
|
||||
result = 31 * result + mTags[i].hashCode();
|
||||
}
|
||||
result = 31 * result + mZoomLevel;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
54
src/org/oscim/theme/MultiKeyMatcher.java
Normal file
54
src/org/oscim/theme/MultiKeyMatcher.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class MultiKeyMatcher implements AttributeMatcher {
|
||||
private final String[] mKeys;
|
||||
|
||||
MultiKeyMatcher(List<String> keys) {
|
||||
mKeys = new String[keys.size()];
|
||||
for (int i = 0, n = mKeys.length; i < n; ++i) {
|
||||
mKeys[i] = keys.get(i).intern();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCoveredBy(AttributeMatcher attributeMatcher) {
|
||||
if (attributeMatcher == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Tag[] tags = new Tag[mKeys.length];
|
||||
int i = 0;
|
||||
for (String key : mKeys) {
|
||||
tags[i++] = new Tag(key, null);
|
||||
}
|
||||
return attributeMatcher.matches(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Tag[] tags) {
|
||||
for (Tag tag : tags)
|
||||
for (String key : mKeys)
|
||||
if (key == tag.key)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
54
src/org/oscim/theme/MultiValueMatcher.java
Normal file
54
src/org/oscim/theme/MultiValueMatcher.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class MultiValueMatcher implements AttributeMatcher {
|
||||
private final String[] mValues;
|
||||
|
||||
MultiValueMatcher(List<String> values) {
|
||||
mValues = new String[values.size()];
|
||||
for (int i = 0, n = mValues.length; i < n; ++i) {
|
||||
mValues[i] = values.get(i).intern();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCoveredBy(AttributeMatcher attributeMatcher) {
|
||||
if (attributeMatcher == this) {
|
||||
return true;
|
||||
}
|
||||
Tag[] tags = new Tag[mValues.length];
|
||||
|
||||
int i = 0;
|
||||
for (String val : mValues) {
|
||||
tags[i++] = new Tag(null, val);
|
||||
}
|
||||
return attributeMatcher.matches(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Tag[] tags) {
|
||||
for (Tag tag : tags)
|
||||
for (String val : mValues)
|
||||
if (val == tag.value)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
66
src/org/oscim/theme/NegativeMatcher.java
Normal file
66
src/org/oscim/theme/NegativeMatcher.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class NegativeMatcher implements AttributeMatcher {
|
||||
private final String[] mKeyList;
|
||||
private final String[] mValueList;
|
||||
private final boolean mExclusive;
|
||||
|
||||
NegativeMatcher(List<String> keyList, List<String> valueList, boolean exclusive) {
|
||||
mKeyList = new String[keyList.size()];
|
||||
for (int i = 0; i < mKeyList.length; i++)
|
||||
mKeyList[i] = keyList.get(i).intern();
|
||||
|
||||
mValueList = new String[valueList.size()];
|
||||
for (int i = 0; i < mValueList.length; i++)
|
||||
mValueList[i] = valueList.get(i).intern();
|
||||
|
||||
mExclusive = exclusive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCoveredBy(AttributeMatcher attributeMatcher) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Tag[] tags) {
|
||||
if (keyListDoesNotContainKeys(tags)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Tag tag : tags) {
|
||||
for (String value : mValueList)
|
||||
if (value == tag.value)
|
||||
return !mExclusive;
|
||||
}
|
||||
return mExclusive;
|
||||
}
|
||||
|
||||
private boolean keyListDoesNotContainKeys(Tag[] tags) {
|
||||
for (Tag tag : tags) {
|
||||
for (String key : mKeyList)
|
||||
if (key == tag.key)
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
43
src/org/oscim/theme/NegativeRule.java
Normal file
43
src/org/oscim/theme/NegativeRule.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class NegativeRule extends Rule {
|
||||
final AttributeMatcher mAttributeMatcher;
|
||||
|
||||
NegativeRule(int element, int closed, byte zoomMin, byte zoomMax,
|
||||
AttributeMatcher attributeMatcher) {
|
||||
super(element, closed, zoomMin, zoomMax);
|
||||
|
||||
mAttributeMatcher = attributeMatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean matchesNode(Tag[] tags, byte zoomLevel) {
|
||||
return mZoomMin <= zoomLevel && mZoomMax >= zoomLevel
|
||||
&& (mElement != Element.WAY)
|
||||
&& mAttributeMatcher.matches(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean matchesWay(Tag[] tags, byte zoomLevel, int closed) {
|
||||
return mZoomMin <= zoomLevel && mZoomMax >= zoomLevel
|
||||
&& (mElement != Element.NODE)
|
||||
&& (mClosed == closed || mClosed == Closed.ANY)
|
||||
&& mAttributeMatcher.matches(tags);
|
||||
}
|
||||
}
|
||||
56
src/org/oscim/theme/PositiveRule.java
Normal file
56
src/org/oscim/theme/PositiveRule.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class PositiveRule extends Rule {
|
||||
final AttributeMatcher mKeyMatcher;
|
||||
final AttributeMatcher mValueMatcher;
|
||||
|
||||
PositiveRule(int element, int closed, byte zoomMin, byte zoomMax,
|
||||
AttributeMatcher keyMatcher, AttributeMatcher valueMatcher) {
|
||||
super(element, closed, zoomMin, zoomMax);
|
||||
|
||||
if (keyMatcher instanceof AnyMatcher)
|
||||
mKeyMatcher = null;
|
||||
else
|
||||
mKeyMatcher = keyMatcher;
|
||||
|
||||
if (valueMatcher instanceof AnyMatcher)
|
||||
mValueMatcher = null;
|
||||
else
|
||||
mValueMatcher = valueMatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean matchesNode(Tag[] tags, byte zoomLevel) {
|
||||
return (mElement != Element.WAY)
|
||||
&& mZoomMin <= zoomLevel
|
||||
&& mZoomMax >= zoomLevel
|
||||
&& (mKeyMatcher == null || mKeyMatcher.matches(tags))
|
||||
&& (mValueMatcher == null || mValueMatcher.matches(tags));
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean matchesWay(Tag[] tags, byte zoomLevel, int closed) {
|
||||
return (mElement != Element.NODE)
|
||||
&& mZoomMin <= zoomLevel
|
||||
&& mZoomMax >= zoomLevel
|
||||
&& (mClosed == closed || mClosed == Closed.ANY)
|
||||
&& (mKeyMatcher == null || mKeyMatcher.matches(tags))
|
||||
&& (mValueMatcher == null || mValueMatcher.matches(tags));
|
||||
}
|
||||
}
|
||||
280
src/org/oscim/theme/RenderTheme.java
Normal file
280
src/org/oscim/theme/RenderTheme.java
Normal file
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.oscim.core.LRUCache;
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
/**
|
||||
* A RenderTheme defines how ways and nodes are drawn.
|
||||
*/
|
||||
public class RenderTheme {
|
||||
private static final int MATCHING_CACHE_SIZE = 1024;
|
||||
private static final int RENDER_THEME_VERSION = 1;
|
||||
|
||||
private static void validate(String elementName, Integer version,
|
||||
float baseStrokeWidth, float baseTextSize) {
|
||||
if (version == null) {
|
||||
throw new IllegalArgumentException("missing attribute version for element:"
|
||||
+ elementName);
|
||||
} else if (version.intValue() != RENDER_THEME_VERSION) {
|
||||
throw new IllegalArgumentException("invalid render theme version:" + version);
|
||||
} else if (baseStrokeWidth < 0) {
|
||||
throw new IllegalArgumentException("base-stroke-width must not be negative: "
|
||||
+ baseStrokeWidth);
|
||||
} else if (baseTextSize < 0) {
|
||||
throw new IllegalArgumentException("base-text-size must not be negative: "
|
||||
+ baseTextSize);
|
||||
}
|
||||
}
|
||||
|
||||
static RenderTheme create(String elementName, Attributes attributes) {
|
||||
Integer version = null;
|
||||
int mapBackground = Color.WHITE;
|
||||
float baseStrokeWidth = 1;
|
||||
float baseTextSize = 1;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
|
||||
if ("schemaLocation".equals(name)) {
|
||||
continue;
|
||||
} else if ("version".equals(name)) {
|
||||
version = Integer.valueOf(Integer.parseInt(value));
|
||||
} else if ("map-background".equals(name)) {
|
||||
mapBackground = Color.parseColor(value);
|
||||
} else if ("base-stroke-width".equals(name)) {
|
||||
baseStrokeWidth = Float.parseFloat(value);
|
||||
} else if ("base-text-size".equals(name)) {
|
||||
baseTextSize = Float.parseFloat(value);
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(elementName, version, baseStrokeWidth, baseTextSize);
|
||||
return new RenderTheme(mapBackground, baseStrokeWidth, baseTextSize);
|
||||
}
|
||||
|
||||
private final float mBaseStrokeWidth;
|
||||
private final float mBaseTextSize;
|
||||
private int mLevels;
|
||||
private final int mMapBackground;
|
||||
private final ArrayList<Rule> mRulesList;
|
||||
|
||||
private final LRUCache<MatchingCacheKey, RenderInstruction[]> mMatchingCacheNodes;
|
||||
private final LRUCache<MatchingCacheKey, RenderInstruction[]> mMatchingCacheWay;
|
||||
private final LRUCache<MatchingCacheKey, RenderInstruction[]> mMatchingCacheArea;
|
||||
|
||||
RenderTheme(int mapBackground, float baseStrokeWidth, float baseTextSize) {
|
||||
mMapBackground = mapBackground;
|
||||
mBaseStrokeWidth = baseStrokeWidth;
|
||||
mBaseTextSize = baseTextSize;
|
||||
mRulesList = new ArrayList<Rule>();
|
||||
|
||||
mMatchingCacheNodes = new LRUCache<MatchingCacheKey, RenderInstruction[]>(
|
||||
MATCHING_CACHE_SIZE);
|
||||
mMatchingCacheWay = new LRUCache<MatchingCacheKey, RenderInstruction[]>(
|
||||
MATCHING_CACHE_SIZE);
|
||||
mMatchingCacheArea = new LRUCache<MatchingCacheKey, RenderInstruction[]>(
|
||||
MATCHING_CACHE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be called when this RenderTheme gets destroyed to clean up and free resources.
|
||||
*/
|
||||
public void destroy() {
|
||||
mMatchingCacheNodes.clear();
|
||||
mMatchingCacheArea.clear();
|
||||
mMatchingCacheWay.clear();
|
||||
|
||||
for (int i = 0, n = mRulesList.size(); i < n; ++i) {
|
||||
mRulesList.get(i).onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of distinct drawing levels required by this RenderTheme.
|
||||
*/
|
||||
public int getLevels() {
|
||||
return mLevels;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the map background color of this RenderTheme.
|
||||
* @see Color
|
||||
*/
|
||||
public int getMapBackground() {
|
||||
return mMapBackground;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderCallback
|
||||
* ...
|
||||
* @param tags
|
||||
* ...
|
||||
* @param zoomLevel
|
||||
* ...
|
||||
* @return ...
|
||||
*/
|
||||
public synchronized RenderInstruction[] matchNode(IRenderCallback renderCallback,
|
||||
Tag[] tags, byte zoomLevel) {
|
||||
|
||||
RenderInstruction[] renderInstructions = null;
|
||||
|
||||
MatchingCacheKey matchingCacheKey;
|
||||
|
||||
matchingCacheKey = new MatchingCacheKey(tags, zoomLevel);
|
||||
boolean found = mMatchingCacheNodes.containsKey(matchingCacheKey);
|
||||
if (found) {
|
||||
renderInstructions = mMatchingCacheNodes.get(matchingCacheKey);
|
||||
} else {
|
||||
// cache miss
|
||||
List<RenderInstruction> matchingList = new ArrayList<RenderInstruction>(4);
|
||||
for (int i = 0, n = mRulesList.size(); i < n; ++i)
|
||||
mRulesList.get(i)
|
||||
.matchNode(renderCallback, tags, zoomLevel, matchingList);
|
||||
|
||||
int size = matchingList.size();
|
||||
if (size > 0) {
|
||||
renderInstructions = new RenderInstruction[size];
|
||||
matchingList.toArray(renderInstructions);
|
||||
}
|
||||
mMatchingCacheNodes.put(matchingCacheKey, renderInstructions);
|
||||
}
|
||||
|
||||
if (renderInstructions != null) {
|
||||
for (int i = 0, n = renderInstructions.length; i < n; i++)
|
||||
renderInstructions[i].renderNode(renderCallback, tags);
|
||||
}
|
||||
|
||||
return renderInstructions;
|
||||
|
||||
}
|
||||
|
||||
// private int missCnt = 0;
|
||||
// private int hitCnt = 0;
|
||||
private MatchingCacheKey mCacheKey = new MatchingCacheKey();
|
||||
|
||||
/**
|
||||
* Matches a way with the given parameters against this RenderTheme.
|
||||
*
|
||||
* @param renderCallback
|
||||
* the callback implementation which will be executed on each match.
|
||||
* @param tags
|
||||
* the tags of the way.
|
||||
* @param zoomLevel
|
||||
* the zoom level at which the way should be matched.
|
||||
* @param closed
|
||||
* way is Closed
|
||||
* @param render
|
||||
* ...
|
||||
* @return currently processed render instructions
|
||||
*/
|
||||
public synchronized RenderInstruction[] matchWay(IRenderCallback renderCallback,
|
||||
Tag[] tags, byte zoomLevel, boolean closed, boolean render) {
|
||||
|
||||
RenderInstruction[] renderInstructions = null;
|
||||
|
||||
LRUCache<MatchingCacheKey, RenderInstruction[]> matchingCache;
|
||||
MatchingCacheKey matchingCacheKey;
|
||||
|
||||
if (closed) {
|
||||
matchingCache = mMatchingCacheArea;
|
||||
} else {
|
||||
matchingCache = mMatchingCacheWay;
|
||||
}
|
||||
|
||||
mCacheKey.set(tags, zoomLevel);
|
||||
renderInstructions = matchingCache.get(mCacheKey);
|
||||
|
||||
if (renderInstructions != null) {
|
||||
// Log.d("RenderTheme", hitCnt++ + "Cache Hit");
|
||||
} else if (!matchingCache.containsKey(mCacheKey)) {
|
||||
matchingCacheKey = new MatchingCacheKey(mCacheKey);
|
||||
|
||||
// cache miss
|
||||
// Log.d("RenderTheme", missCnt++ + " Cache Miss");
|
||||
|
||||
int c = (closed ? Closed.YES : Closed.NO);
|
||||
List<RenderInstruction> matchingList = new ArrayList<RenderInstruction>(4);
|
||||
for (int i = 0, n = mRulesList.size(); i < n; ++i) {
|
||||
mRulesList.get(i).matchWay(renderCallback, tags, zoomLevel, c,
|
||||
matchingList);
|
||||
}
|
||||
int size = matchingList.size();
|
||||
if (size > 0) {
|
||||
renderInstructions = new RenderInstruction[size];
|
||||
matchingList.toArray(renderInstructions);
|
||||
}
|
||||
matchingCache.put(matchingCacheKey, renderInstructions);
|
||||
}
|
||||
|
||||
if (render && renderInstructions != null) {
|
||||
for (int i = 0, n = renderInstructions.length; i < n; i++)
|
||||
renderInstructions[i].renderWay(renderCallback, tags);
|
||||
}
|
||||
|
||||
return renderInstructions;
|
||||
}
|
||||
|
||||
void addRule(Rule rule) {
|
||||
mRulesList.add(rule);
|
||||
}
|
||||
|
||||
void complete() {
|
||||
mRulesList.trimToSize();
|
||||
for (int i = 0, n = mRulesList.size(); i < n; ++i) {
|
||||
mRulesList.get(i).onComplete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the stroke width of this RenderTheme by the given factor.
|
||||
*
|
||||
* @param scaleFactor
|
||||
* the factor by which the stroke width should be scaled.
|
||||
*/
|
||||
public void scaleStrokeWidth(float scaleFactor) {
|
||||
for (int i = 0, n = mRulesList.size(); i < n; ++i) {
|
||||
mRulesList.get(i).scaleStrokeWidth(scaleFactor * mBaseStrokeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the text size of this RenderTheme by the given factor.
|
||||
*
|
||||
* @param scaleFactor
|
||||
* the factor by which the text size should be scaled.
|
||||
*/
|
||||
public void scaleTextSize(float scaleFactor) {
|
||||
for (int i = 0, n = mRulesList.size(); i < n; ++i) {
|
||||
mRulesList.get(i).scaleTextSize(scaleFactor * mBaseTextSize);
|
||||
}
|
||||
}
|
||||
|
||||
void setLevels(int levels) {
|
||||
mLevels = levels;
|
||||
}
|
||||
}
|
||||
358
src/org/oscim/theme/RenderThemeHandler.java
Normal file
358
src/org/oscim/theme/RenderThemeHandler.java
Normal file
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.oscim.theme.renderinstruction.Area;
|
||||
import org.oscim.theme.renderinstruction.AreaLevel;
|
||||
import org.oscim.theme.renderinstruction.Caption;
|
||||
import org.oscim.theme.renderinstruction.Circle;
|
||||
import org.oscim.theme.renderinstruction.Line;
|
||||
import org.oscim.theme.renderinstruction.LineSymbol;
|
||||
import org.oscim.theme.renderinstruction.PathText;
|
||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
||||
import org.oscim.theme.renderinstruction.Symbol;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* SAX2 handler to parse XML render theme files.
|
||||
*/
|
||||
public class RenderThemeHandler extends DefaultHandler {
|
||||
private static final Logger LOG = Logger
|
||||
.getLogger(RenderThemeHandler.class.getName());
|
||||
|
||||
private static enum Element {
|
||||
RENDER_THEME, RENDERING_INSTRUCTION, RULE, STYLE;
|
||||
}
|
||||
|
||||
private static final String ELEMENT_NAME_RENDER_THEME = "rendertheme";
|
||||
private static final String ELEMENT_NAME_RULE = "rule";
|
||||
private static final String ELEMENT_NAME_STYPE_PATH_TEXT = "style-pathtext";
|
||||
private static final String ELEMENT_NAME_STYLE_AREA = "style-area";
|
||||
private static final String ELEMENT_NAME_STYLE_LINE = "style-line";
|
||||
private static final String ELEMENT_NAME_STYLE_OUTLINE = "style-outline";
|
||||
private static final String ELEMENT_NAME_USE_STYLE_PATH_TEXT = "use-text";
|
||||
private static final String ELEMENT_NAME_USE_STYLE_AREA = "use-area";
|
||||
private static final String ELEMENT_NAME_USE_STYLE_LINE = "use-line";
|
||||
private static final String ELEMENT_NAME_USE_STYLE_OUTLINE = "use-outline";
|
||||
private static final String UNEXPECTED_ELEMENT = "unexpected element: ";
|
||||
|
||||
/**
|
||||
* @param inputStream
|
||||
* an input stream containing valid render theme XML data.
|
||||
* @return a new RenderTheme which is created by parsing the XML data from the input stream.
|
||||
* @throws SAXException
|
||||
* if an error occurs while parsing the render theme XML.
|
||||
* @throws ParserConfigurationException
|
||||
* if an error occurs while creating the XML parser.
|
||||
* @throws IOException
|
||||
* if an I/O error occurs while reading from the input stream.
|
||||
*/
|
||||
public static RenderTheme getRenderTheme(InputStream inputStream)
|
||||
throws SAXException,
|
||||
ParserConfigurationException, IOException {
|
||||
RenderThemeHandler renderThemeHandler = new RenderThemeHandler();
|
||||
XMLReader xmlReader = SAXParserFactory.newInstance().newSAXParser()
|
||||
.getXMLReader();
|
||||
xmlReader.setContentHandler(renderThemeHandler);
|
||||
xmlReader.parse(new InputSource(inputStream));
|
||||
return renderThemeHandler.mRenderTheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the given information about an unknown XML attribute.
|
||||
*
|
||||
* @param element
|
||||
* the XML element name.
|
||||
* @param name
|
||||
* the XML attribute name.
|
||||
* @param value
|
||||
* the XML attribute value.
|
||||
* @param attributeIndex
|
||||
* the XML attribute index position.
|
||||
*/
|
||||
public static void logUnknownAttribute(String element, String name, String value,
|
||||
int attributeIndex) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("unknown attribute in element ");
|
||||
stringBuilder.append(element);
|
||||
stringBuilder.append(" (");
|
||||
stringBuilder.append(attributeIndex);
|
||||
stringBuilder.append("): ");
|
||||
stringBuilder.append(name);
|
||||
stringBuilder.append('=');
|
||||
stringBuilder.append(value);
|
||||
LOG.info(stringBuilder.toString());
|
||||
}
|
||||
|
||||
private Rule mCurrentRule;
|
||||
private final Stack<Element> mElementStack = new Stack<Element>();
|
||||
private int mLevel;
|
||||
private RenderTheme mRenderTheme;
|
||||
private final Stack<Rule> mRuleStack = new Stack<Rule>();
|
||||
|
||||
@Override
|
||||
public void endDocument() {
|
||||
if (mRenderTheme == null) {
|
||||
throw new IllegalArgumentException("missing element: rules");
|
||||
}
|
||||
|
||||
mRenderTheme.setLevels(mLevel);
|
||||
mRenderTheme.complete();
|
||||
tmpStyleHash.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) {
|
||||
mElementStack.pop();
|
||||
|
||||
if (ELEMENT_NAME_RULE.equals(localName)) {
|
||||
mRuleStack.pop();
|
||||
if (mRuleStack.empty()) {
|
||||
mRenderTheme.addRule(mCurrentRule);
|
||||
} else {
|
||||
mCurrentRule = mRuleStack.peek();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(SAXParseException exception) {
|
||||
LOG.log(Level.SEVERE, null, exception);
|
||||
}
|
||||
|
||||
private static HashMap<String, RenderInstruction> tmpStyleHash = new HashMap<String, RenderInstruction>(
|
||||
10);
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName,
|
||||
Attributes attributes) throws SAXException {
|
||||
try {
|
||||
if (ELEMENT_NAME_RENDER_THEME.equals(localName)) {
|
||||
checkState(localName, Element.RENDER_THEME);
|
||||
mRenderTheme = RenderTheme.create(localName, attributes);
|
||||
}
|
||||
|
||||
else if (ELEMENT_NAME_RULE.equals(localName)) {
|
||||
checkState(localName, Element.RULE);
|
||||
Rule rule = Rule.create(localName, attributes, mRuleStack);
|
||||
if (!mRuleStack.empty()) {
|
||||
mCurrentRule.addSubRule(rule);
|
||||
}
|
||||
mCurrentRule = rule;
|
||||
mRuleStack.push(mCurrentRule);
|
||||
}
|
||||
|
||||
else if (ELEMENT_NAME_STYPE_PATH_TEXT.equals(localName)) {
|
||||
checkState(localName, Element.STYLE);
|
||||
PathText pathText = PathText.create(localName, attributes);
|
||||
tmpStyleHash.put("t" + pathText.style, pathText);
|
||||
// System.out.println("add style: " + pathText.style);
|
||||
}
|
||||
|
||||
else if (ELEMENT_NAME_STYLE_AREA.equals(localName)) {
|
||||
checkState(localName, Element.STYLE);
|
||||
Area area = Area.create(localName, attributes, 0);
|
||||
tmpStyleHash.put("a" + area.style, area);
|
||||
// System.out.println("add style: " + area.style);
|
||||
}
|
||||
|
||||
else if (ELEMENT_NAME_STYLE_LINE.equals(localName)) {
|
||||
checkState(localName, Element.STYLE);
|
||||
String style = null;
|
||||
if ((style = attributes.getValue("from")) != null) {
|
||||
RenderInstruction ri = tmpStyleHash.get("l" + style);
|
||||
if (ri instanceof Line) {
|
||||
Line line = Line.create((Line) ri, localName, attributes, 0,
|
||||
false);
|
||||
tmpStyleHash.put("l" + line.style, line);
|
||||
// System.out.println("add style: " + line.style + " from " + style);
|
||||
}
|
||||
else {
|
||||
Log.d("...", "this aint no style! " + style);
|
||||
}
|
||||
} else {
|
||||
Line line = Line.create(null, localName, attributes, 0, false);
|
||||
tmpStyleHash.put("l" + line.style, line);
|
||||
// System.out.println("add style: " + line.style);
|
||||
}
|
||||
}
|
||||
|
||||
else if (ELEMENT_NAME_STYLE_OUTLINE.equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
Line line = Line.create(null, localName, attributes, mLevel++, true);
|
||||
tmpStyleHash.put("o" + line.style, line);
|
||||
// outlineLayers.add(line);
|
||||
}
|
||||
|
||||
else if ("area".equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
Area area = Area.create(localName, attributes, mLevel++);
|
||||
// mRuleStack.peek().addRenderingInstruction(area);
|
||||
mCurrentRule.addRenderingInstruction(area);
|
||||
}
|
||||
|
||||
else if ("caption".equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
Caption caption = Caption.create(localName, attributes);
|
||||
mCurrentRule.addRenderingInstruction(caption);
|
||||
}
|
||||
|
||||
else if ("circle".equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
Circle circle = Circle.create(localName, attributes, mLevel++);
|
||||
mCurrentRule.addRenderingInstruction(circle);
|
||||
}
|
||||
|
||||
else if ("line".equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
Line line = Line.create(null, localName, attributes, mLevel++, false);
|
||||
mCurrentRule.addRenderingInstruction(line);
|
||||
}
|
||||
|
||||
else if ("lineSymbol".equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
LineSymbol lineSymbol = LineSymbol.create(localName, attributes);
|
||||
mCurrentRule.addRenderingInstruction(lineSymbol);
|
||||
}
|
||||
|
||||
else if ("pathText".equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
PathText pathText = PathText.create(localName, attributes);
|
||||
mCurrentRule.addRenderingInstruction(pathText);
|
||||
}
|
||||
|
||||
else if ("symbol".equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
Symbol symbol = Symbol.create(localName, attributes);
|
||||
mCurrentRule.addRenderingInstruction(symbol);
|
||||
}
|
||||
|
||||
else if (ELEMENT_NAME_USE_STYLE_LINE.equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
String style = attributes.getValue("name");
|
||||
if (style != null) {
|
||||
Line line = (Line) tmpStyleHash.get("l" + style);
|
||||
if (line != null) {
|
||||
// System.out.println("found style line : " + line.style);
|
||||
Line newLine = Line.create(line, localName, attributes,
|
||||
mLevel++, false);
|
||||
|
||||
mCurrentRule.addRenderingInstruction(newLine);
|
||||
}
|
||||
else
|
||||
Log.d("...", "styles not a line! " + style);
|
||||
}
|
||||
} else if (ELEMENT_NAME_USE_STYLE_OUTLINE.equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
String style = attributes.getValue("name");
|
||||
if (style != null) {
|
||||
Line line = (Line) tmpStyleHash.get("o" + style);
|
||||
if (line != null && line.outline)
|
||||
mCurrentRule.addRenderingInstruction(line);
|
||||
else
|
||||
Log.d("...", "styles not bad, but this aint no outline! " + style);
|
||||
}
|
||||
} else if (ELEMENT_NAME_USE_STYLE_AREA.equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
String style = attributes.getValue("name");
|
||||
if (style != null) {
|
||||
Area area = (Area) tmpStyleHash.get("a" + style);
|
||||
if (area != null)
|
||||
mCurrentRule.addRenderingInstruction(new AreaLevel(area,
|
||||
mLevel++));
|
||||
else
|
||||
Log.d("...", "this aint no style inna di area! " + style);
|
||||
}
|
||||
} else if (ELEMENT_NAME_USE_STYLE_PATH_TEXT.equals(localName)) {
|
||||
checkState(localName, Element.RENDERING_INSTRUCTION);
|
||||
String style = attributes.getValue("name");
|
||||
if (style != null) {
|
||||
PathText pt = (PathText) tmpStyleHash.get("t" + style);
|
||||
if (pt != null)
|
||||
mCurrentRule.addRenderingInstruction(pt);
|
||||
else
|
||||
Log.d("...", "this aint no path text style! " + style);
|
||||
}
|
||||
} else {
|
||||
throw new SAXException("unknown element: " + localName);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new SAXException(null, e);
|
||||
} catch (IOException e) {
|
||||
throw new SAXException(null, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(SAXParseException exception) {
|
||||
LOG.log(Level.SEVERE, null, exception);
|
||||
}
|
||||
|
||||
private void checkElement(String elementName, Element element) throws SAXException {
|
||||
Element parentElement;
|
||||
switch (element) {
|
||||
case RENDER_THEME:
|
||||
if (!mElementStack.empty()) {
|
||||
throw new SAXException(UNEXPECTED_ELEMENT + elementName);
|
||||
}
|
||||
return;
|
||||
|
||||
case RULE:
|
||||
parentElement = mElementStack.peek();
|
||||
if (parentElement != Element.RENDER_THEME
|
||||
&& parentElement != Element.RULE) {
|
||||
throw new SAXException(UNEXPECTED_ELEMENT + elementName);
|
||||
}
|
||||
return;
|
||||
|
||||
case STYLE:
|
||||
parentElement = mElementStack.peek();
|
||||
if (parentElement != Element.RENDER_THEME) {
|
||||
throw new SAXException(UNEXPECTED_ELEMENT + elementName);
|
||||
}
|
||||
return;
|
||||
|
||||
case RENDERING_INSTRUCTION:
|
||||
if (mElementStack.peek() != Element.RULE) {
|
||||
throw new SAXException(UNEXPECTED_ELEMENT + elementName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
throw new SAXException("unknown enum value: " + element);
|
||||
}
|
||||
|
||||
private void checkState(String elementName, Element element) throws SAXException {
|
||||
checkElement(elementName, element);
|
||||
mElementStack.push(element);
|
||||
}
|
||||
}
|
||||
278
src/org/oscim/theme/Rule.java
Normal file
278
src/org/oscim/theme/Rule.java
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
abstract class Rule {
|
||||
private static final Map<List<String>, AttributeMatcher> MATCHERS_CACHE_KEY = new HashMap<List<String>, AttributeMatcher>();
|
||||
private static final Map<List<String>, AttributeMatcher> MATCHERS_CACHE_VALUE = new HashMap<List<String>, AttributeMatcher>();
|
||||
private static final Pattern SPLIT_PATTERN = Pattern.compile("\\|");
|
||||
private static final String STRING_NEGATION = "~";
|
||||
private static final String STRING_EXCLUSIVE = "-";
|
||||
private static final String STRING_WILDCARD = "*";
|
||||
|
||||
private static Rule createRule(Stack<Rule> ruleStack, int element, String keys,
|
||||
String values, int closed,
|
||||
byte zoomMin, byte zoomMax) {
|
||||
|
||||
List<String> keyList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN
|
||||
.split(keys)));
|
||||
List<String> valueList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN
|
||||
.split(values)));
|
||||
|
||||
if (valueList.remove(STRING_NEGATION)) {
|
||||
AttributeMatcher attributeMatcher = new NegativeMatcher(keyList, valueList,
|
||||
false);
|
||||
return new NegativeRule(element, closed, zoomMin, zoomMax,
|
||||
attributeMatcher);
|
||||
}
|
||||
|
||||
if (valueList.remove(STRING_EXCLUSIVE)) {
|
||||
AttributeMatcher attributeMatcher = new NegativeMatcher(keyList, valueList,
|
||||
true);
|
||||
return new NegativeRule(element, closed, zoomMin, zoomMax,
|
||||
attributeMatcher);
|
||||
}
|
||||
AttributeMatcher keyMatcher = getKeyMatcher(keyList);
|
||||
AttributeMatcher valueMatcher = getValueMatcher(valueList);
|
||||
|
||||
keyMatcher = RuleOptimizer.optimize(keyMatcher, ruleStack);
|
||||
valueMatcher = RuleOptimizer.optimize(valueMatcher, ruleStack);
|
||||
|
||||
return new PositiveRule(element, closed, zoomMin, zoomMax,
|
||||
keyMatcher, valueMatcher);
|
||||
}
|
||||
|
||||
private static AttributeMatcher getKeyMatcher(List<String> keyList) {
|
||||
if (STRING_WILDCARD.equals(keyList.get(0))) {
|
||||
return AnyMatcher.getInstance();
|
||||
}
|
||||
|
||||
AttributeMatcher attributeMatcher = MATCHERS_CACHE_KEY.get(keyList);
|
||||
if (attributeMatcher == null) {
|
||||
if (keyList.size() == 1) {
|
||||
attributeMatcher = new SingleKeyMatcher(keyList.get(0));
|
||||
} else {
|
||||
attributeMatcher = new MultiKeyMatcher(keyList);
|
||||
}
|
||||
MATCHERS_CACHE_KEY.put(keyList, attributeMatcher);
|
||||
}
|
||||
return attributeMatcher;
|
||||
}
|
||||
|
||||
private static AttributeMatcher getValueMatcher(List<String> valueList) {
|
||||
if (STRING_WILDCARD.equals(valueList.get(0))) {
|
||||
return AnyMatcher.getInstance();
|
||||
}
|
||||
|
||||
AttributeMatcher attributeMatcher = MATCHERS_CACHE_VALUE.get(valueList);
|
||||
if (attributeMatcher == null) {
|
||||
if (valueList.size() == 1) {
|
||||
attributeMatcher = new SingleValueMatcher(valueList.get(0));
|
||||
} else {
|
||||
attributeMatcher = new MultiValueMatcher(valueList);
|
||||
}
|
||||
MATCHERS_CACHE_VALUE.put(valueList, attributeMatcher);
|
||||
}
|
||||
return attributeMatcher;
|
||||
}
|
||||
|
||||
private static void validate(String elementName, String keys, String values,
|
||||
byte zoomMin, byte zoomMax) {
|
||||
if (keys == null) {
|
||||
throw new IllegalArgumentException("missing attribute k for element: "
|
||||
+ elementName);
|
||||
} else if (values == null) {
|
||||
throw new IllegalArgumentException("missing attribute v for element: "
|
||||
+ elementName);
|
||||
} else if (zoomMin < 0) {
|
||||
throw new IllegalArgumentException("zoom-min must not be negative: "
|
||||
+ zoomMin);
|
||||
} else if (zoomMax < 0) {
|
||||
throw new IllegalArgumentException("zoom-max must not be negative: "
|
||||
+ zoomMax);
|
||||
} else if (zoomMin > zoomMax) {
|
||||
throw new IllegalArgumentException(
|
||||
"zoom-min must be less or equal zoom-max: " + zoomMin);
|
||||
}
|
||||
}
|
||||
|
||||
static Rule create(String elementName, Attributes attributes, Stack<Rule> ruleStack) {
|
||||
int element = Element.ANY;
|
||||
String keys = null;
|
||||
String values = null;
|
||||
int closed = Closed.ANY;
|
||||
byte zoomMin = 0;
|
||||
byte zoomMax = Byte.MAX_VALUE;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
|
||||
if ("e".equals(name)) {
|
||||
String val = value.toUpperCase(Locale.ENGLISH);
|
||||
if ("WAY".equals(val))
|
||||
element = Element.WAY;
|
||||
else if ("NODE".equals(val))
|
||||
element = Element.NODE;
|
||||
} else if ("k".equals(name)) {
|
||||
keys = value;
|
||||
} else if ("v".equals(name)) {
|
||||
values = value;
|
||||
} else if ("closed".equals(name)) {
|
||||
String val = value.toUpperCase(Locale.ENGLISH);
|
||||
if ("YES".equals(val))
|
||||
closed = Closed.YES;
|
||||
else if ("NO".equals(val))
|
||||
closed = Closed.NO;
|
||||
} else if ("zoom-min".equals(name)) {
|
||||
zoomMin = Byte.parseByte(value);
|
||||
} else if ("zoom-max".equals(name)) {
|
||||
zoomMax = Byte.parseByte(value);
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(elementName, keys, values, zoomMin, zoomMax);
|
||||
return createRule(ruleStack, element, keys, values, closed, zoomMin, zoomMax);
|
||||
}
|
||||
|
||||
private ArrayList<RenderInstruction> mRenderInstructions;
|
||||
private ArrayList<Rule> mSubRules;
|
||||
|
||||
private Rule[] mSubRuleArray;
|
||||
private RenderInstruction[] mRenderInstructionArray;
|
||||
|
||||
final byte mZoomMax;
|
||||
final byte mZoomMin;
|
||||
final int mElement;
|
||||
final int mClosed;
|
||||
|
||||
Rule(int element, int closed, byte zoomMin,
|
||||
byte zoomMax) {
|
||||
|
||||
mClosed = closed;
|
||||
mElement = element;
|
||||
mZoomMin = zoomMin;
|
||||
mZoomMax = zoomMax;
|
||||
|
||||
mRenderInstructions = new ArrayList<RenderInstruction>(4);
|
||||
mSubRules = new ArrayList<Rule>(4);
|
||||
}
|
||||
|
||||
void addRenderingInstruction(RenderInstruction renderInstruction) {
|
||||
mRenderInstructions.add(renderInstruction);
|
||||
}
|
||||
|
||||
void addSubRule(Rule rule) {
|
||||
mSubRules.add(rule);
|
||||
}
|
||||
|
||||
abstract boolean matchesNode(Tag[] tags, byte zoomLevel);
|
||||
|
||||
abstract boolean matchesWay(Tag[] tags, byte zoomLevel, int closed);
|
||||
|
||||
void matchNode(IRenderCallback renderCallback, Tag[] tags, byte zoomLevel,
|
||||
List<RenderInstruction> matchingList) {
|
||||
if (matchesNode(tags, zoomLevel)) {
|
||||
for (int i = 0, n = mRenderInstructionArray.length; i < n; i++)
|
||||
matchingList.add(mRenderInstructionArray[i]);
|
||||
|
||||
for (int i = 0, n = mSubRuleArray.length; i < n; i++)
|
||||
mSubRuleArray[i].matchNode(renderCallback, tags, zoomLevel, matchingList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void matchWay(IRenderCallback renderCallback, Tag[] tags, byte zoomLevel,
|
||||
int closed,
|
||||
List<RenderInstruction> matchingList) {
|
||||
|
||||
if (matchesWay(tags, zoomLevel, closed)) {
|
||||
for (int i = 0, n = mRenderInstructionArray.length; i < n; i++)
|
||||
matchingList.add(mRenderInstructionArray[i]);
|
||||
|
||||
for (int i = 0, n = mSubRuleArray.length; i < n; i++)
|
||||
mSubRuleArray[i].matchWay(renderCallback, tags, zoomLevel, closed,
|
||||
matchingList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void onComplete() {
|
||||
MATCHERS_CACHE_KEY.clear();
|
||||
MATCHERS_CACHE_VALUE.clear();
|
||||
|
||||
mRenderInstructionArray = new RenderInstruction[mRenderInstructions.size()];
|
||||
mRenderInstructions.toArray(mRenderInstructionArray);
|
||||
// for (int i = 0, n = mRenderInstructions.size(); i < n; i++)
|
||||
// mRenderInstructionArray[i] = mRenderInstructions.get(i);
|
||||
|
||||
mSubRuleArray = new Rule[mSubRules.size()];
|
||||
mSubRules.toArray(mSubRuleArray);
|
||||
|
||||
// for (int i = 0, n = mSubRules.size(); i < n; i++)
|
||||
// mSubRuleArray[i] = mSubRules.get(i);
|
||||
|
||||
mRenderInstructions.clear();
|
||||
mRenderInstructions = null;
|
||||
mSubRules.clear();
|
||||
mSubRules = null;
|
||||
|
||||
for (int i = 0, n = mSubRuleArray.length; i < n; i++)
|
||||
mSubRuleArray[i].onComplete();
|
||||
|
||||
}
|
||||
|
||||
void onDestroy() {
|
||||
for (int i = 0, n = mRenderInstructionArray.length; i < n; i++)
|
||||
mRenderInstructionArray[i].destroy();
|
||||
|
||||
for (int i = 0, n = mSubRuleArray.length; i < n; i++)
|
||||
mSubRuleArray[i].onDestroy();
|
||||
|
||||
}
|
||||
|
||||
void scaleStrokeWidth(float scaleFactor) {
|
||||
for (int i = 0, n = mRenderInstructionArray.length; i < n; i++)
|
||||
mRenderInstructionArray[i].scaleStrokeWidth(scaleFactor);
|
||||
|
||||
for (int i = 0, n = mSubRuleArray.length; i < n; i++)
|
||||
mSubRuleArray[i].scaleStrokeWidth(scaleFactor);
|
||||
|
||||
}
|
||||
|
||||
void scaleTextSize(float scaleFactor) {
|
||||
for (int i = 0, n = mRenderInstructionArray.length; i < n; i++)
|
||||
mRenderInstructionArray[i].scaleTextSize(scaleFactor);
|
||||
|
||||
for (int i = 0, n = mSubRuleArray.length; i < n; i++)
|
||||
mSubRuleArray[i].scaleTextSize(scaleFactor);
|
||||
|
||||
}
|
||||
}
|
||||
130
src/org/oscim/theme/RuleOptimizer.java
Normal file
130
src/org/oscim/theme/RuleOptimizer.java
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
final class RuleOptimizer {
|
||||
// private static final Logger LOG = Logger.getLogger(RuleOptimizer.class.getName());
|
||||
|
||||
private static AttributeMatcher optimizeKeyMatcher(AttributeMatcher attributeMatcher,
|
||||
Stack<Rule> ruleStack) {
|
||||
for (int i = 0, n = ruleStack.size(); i < n; ++i) {
|
||||
if (ruleStack.get(i) instanceof PositiveRule) {
|
||||
PositiveRule positiveRule = (PositiveRule) ruleStack.get(i);
|
||||
if (positiveRule.mKeyMatcher != null
|
||||
&& positiveRule.mKeyMatcher.isCoveredBy(attributeMatcher)) {
|
||||
return null; // AnyMatcher.getInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return attributeMatcher;
|
||||
}
|
||||
|
||||
private static AttributeMatcher optimizeValueMatcher(
|
||||
AttributeMatcher attributeMatcher, Stack<Rule> ruleStack) {
|
||||
for (int i = 0, n = ruleStack.size(); i < n; ++i) {
|
||||
if (ruleStack.get(i) instanceof PositiveRule) {
|
||||
PositiveRule positiveRule = (PositiveRule) ruleStack.get(i);
|
||||
|
||||
if (positiveRule.mValueMatcher != null
|
||||
&& positiveRule.mValueMatcher.isCoveredBy(attributeMatcher)) {
|
||||
return null; // AnyMatcher.getInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return attributeMatcher;
|
||||
}
|
||||
|
||||
static AttributeMatcher optimize(AttributeMatcher attributeMatcher,
|
||||
Stack<Rule> ruleStack) {
|
||||
if (attributeMatcher instanceof AnyMatcher)
|
||||
return attributeMatcher;// return null;
|
||||
else if (attributeMatcher instanceof NegativeMatcher) {
|
||||
return attributeMatcher;
|
||||
} else if (attributeMatcher instanceof SingleKeyMatcher) {
|
||||
return optimizeKeyMatcher(attributeMatcher, ruleStack);
|
||||
} else if (attributeMatcher instanceof SingleValueMatcher) {
|
||||
return optimizeValueMatcher(attributeMatcher, ruleStack);
|
||||
} else if (attributeMatcher instanceof MultiKeyMatcher) {
|
||||
return optimizeKeyMatcher(attributeMatcher, ruleStack);
|
||||
} else if (attributeMatcher instanceof MultiValueMatcher) {
|
||||
return optimizeValueMatcher(attributeMatcher, ruleStack);
|
||||
}
|
||||
throw new IllegalArgumentException("unknown AttributeMatcher: "
|
||||
+ attributeMatcher);
|
||||
}
|
||||
|
||||
// static ClosedMatcher optimize(ClosedMatcher closedMatcher, Stack<Rule> ruleStack) {
|
||||
// if (closedMatcher == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (closedMatcher instanceof AnyMatcher) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// for (int i = 0, n = ruleStack.size(); i < n; ++i) {
|
||||
// ClosedMatcher matcher = ruleStack.get(i).mClosedMatcher;
|
||||
// if (matcher == null)
|
||||
// return null;
|
||||
//
|
||||
// if (matcher.isCoveredBy(closedMatcher)) {
|
||||
// return null; // AnyMatcher.getInstance();
|
||||
//
|
||||
// } else if (!closedMatcher.isCoveredBy(ruleStack.get(i).mClosedMatcher)) {
|
||||
// LOG.warning("unreachable rule (closed)");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return closedMatcher;
|
||||
// }
|
||||
//
|
||||
// static ElementMatcher optimize(ElementMatcher elementMatcher, Stack<Rule> ruleStack) {
|
||||
//
|
||||
// if (elementMatcher == null) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// if (elementMatcher instanceof AnyMatcher) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// for (int i = 0, n = ruleStack.size(); i < n; ++i) {
|
||||
// ElementMatcher matcher = ruleStack.get(i).mElementMatcher;
|
||||
//
|
||||
// if (matcher == null)
|
||||
// return null;
|
||||
//
|
||||
// if (matcher.isCoveredBy(elementMatcher)) {
|
||||
// return null; // AnyMatcher.getInstance();
|
||||
//
|
||||
// } else if (!elementMatcher.isCoveredBy(ruleStack.get(i).mElementMatcher)) {
|
||||
// LOG.warning("unreachable rule (e)");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return elementMatcher;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Private constructor to prevent instantiation from other classes.
|
||||
*/
|
||||
private RuleOptimizer() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
41
src/org/oscim/theme/SingleKeyMatcher.java
Normal file
41
src/org/oscim/theme/SingleKeyMatcher.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class SingleKeyMatcher implements AttributeMatcher {
|
||||
private final String mKey;
|
||||
|
||||
SingleKeyMatcher(String key) {
|
||||
mKey = key.intern();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCoveredBy(AttributeMatcher attributeMatcher) {
|
||||
Tag[] tags = { new Tag(mKey, null) };
|
||||
|
||||
return attributeMatcher == this || attributeMatcher.matches(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Tag[] tags) {
|
||||
for (Tag tag : tags)
|
||||
if (mKey == tag.key)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
41
src/org/oscim/theme/SingleValueMatcher.java
Normal file
41
src/org/oscim/theme/SingleValueMatcher.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
class SingleValueMatcher implements AttributeMatcher {
|
||||
private final String mValue;
|
||||
|
||||
SingleValueMatcher(String value) {
|
||||
mValue = value.intern();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCoveredBy(AttributeMatcher attributeMatcher) {
|
||||
Tag[] tags = { new Tag(null, mValue) };
|
||||
|
||||
return attributeMatcher == this || attributeMatcher.matches(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(Tag[] tags) {
|
||||
for (Tag tag : tags)
|
||||
if (mValue == tag.value)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
28
src/org/oscim/theme/Theme.java
Normal file
28
src/org/oscim/theme/Theme.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface Theme extends Serializable {
|
||||
/**
|
||||
* @return an InputStream to read the render theme data from.
|
||||
* @throws FileNotFoundException
|
||||
* if the render theme file cannot be found.
|
||||
*/
|
||||
InputStream getRenderThemeAsStream() throws FileNotFoundException;
|
||||
}
|
||||
974
src/org/oscim/theme/osmarender/osmarender.xml
Normal file
974
src/org/oscim/theme/osmarender/osmarender.xml
Normal file
@@ -0,0 +1,974 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rendertheme xmlns="http://mapsforge.org/renderTheme"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://mapsforge.org/renderTheme ../renderTheme.xsd"
|
||||
version="1" map-background="#fcfcfa">
|
||||
|
||||
<style-pathtext name="road" k="name" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
|
||||
<style-pathtext name="major-road" k="name" font-style="bold" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
|
||||
|
||||
<style-area name="residential" fill="#f0f0ec" fade="10"/>
|
||||
|
||||
<style-area name="railway|industrial" fill="#f2eeef" fade="10"/>
|
||||
<!-- "#f0fae7" mint green -->
|
||||
<style-area name="farmland" fill="#fff8bf" fade="11" />
|
||||
|
||||
<!-- fade out at z=7, blend over to 'blend-fill' in z=11 -->
|
||||
<style-area name="forest|wood" fill="#ebefe5" fade="7" blend="11" blend-fill="#d3dec8"/>
|
||||
|
||||
<!-- grass|meadow|garden|grassland|scrub -->
|
||||
<style-area name="greens" fill="#ebf2d2" fade="10" />
|
||||
|
||||
<!-- marsh|wetland|nature_reserve -->
|
||||
<style-area name="greens2" fill="#deecb9" fade="12" />
|
||||
|
||||
<!-- park|common|green|cemetery|golf_course|dog_park -->
|
||||
<style-area name="park" fill="#d7e6b0" fade="11" />
|
||||
|
||||
<!-- de:Kleingartengebiet -->
|
||||
<style-area name="allotments" fill="#efeae0" fade="12" />
|
||||
|
||||
<!-- de:Steinbruch, Schotter-, Kies-, Sand- und Tongrube -->
|
||||
<style-area name="quarry" fill="#ddddcc" fade="10" />
|
||||
|
||||
<style-area name="military" fill="#eeedea" fade="10"/>
|
||||
|
||||
|
||||
<style-line name="residential" stroke="#ffffff" width="1.3" />
|
||||
<style-line name="residential:bridge" from="residential" cap="square"/>
|
||||
|
||||
<!-- when inheriting another style with 'from' then 'witdth' is meant relative to the parent -->
|
||||
<style-line name="pedestrian" from="residential" width="-0.4"/>
|
||||
<style-line name="pedestrian:bridge" from="pedestrian" cap="square"/>
|
||||
|
||||
<style-line name="highway:z11" stroke="#fcba5a" width="1.8" />
|
||||
<!-- <style-line name="highway:z11:bridge" from="highway:z11" cap="butt" /> -->
|
||||
|
||||
<style-line name="trunk_link" stroke="#fee16e" width="1.3" cap="butt"/>
|
||||
<style-line name="trunk" stroke="#fedb52" width="1.6"/>
|
||||
<style-line name="primary:z11" stroke="#fff000" width="1.5"/>
|
||||
<style-line name="secondary:z11" from="primary:z11" width="-0.1"/>
|
||||
|
||||
<style-line name="tertiary" from="residential" width="0.2" />
|
||||
<style-line name="construction" stroke="#e0e0e0" width="1.2" />
|
||||
|
||||
<style-line name="highway-service" from="residential" width="-0.6" />
|
||||
|
||||
<!-- track|footway|path|cycleway -->
|
||||
<style-line name="footway" stroke="#c1bcb6" width="1.2" cap="butt" fixed="true"/>
|
||||
<style-line name="footway:z16" from="footway" width="-1.0" fixed="false" fade="-1"/>
|
||||
<style-line name="footway:z17" stroke="#faf8f5" width="0.3"/>
|
||||
|
||||
<!-- de: ein Weg der für Reiter vorgeshen ist.. -->
|
||||
<style-line name="bridleway" stroke="#d3cb98" width="0.4" cap="butt"/>
|
||||
|
||||
<style-line name="steps" stroke="#f1f0f4" width="0.25" cap="butt" />
|
||||
|
||||
<style-line name="water:outline" stroke="#a4bbcc" width="1.0" fixed="true" cap="butt" />
|
||||
<style-line name="water" stroke="#b4cbdc" width="1.0" cap="butt" />
|
||||
<style-area name="water" fill="#b4cbdc" />
|
||||
<!-- no-go area boundary -->
|
||||
<style-line name="fence" stroke="#444444" width="1.2" fixed="true" cap="butt"/>
|
||||
|
||||
<style-line name="aeroway:runway" stroke="#c8ccbe" width="1.8" cap="butt" />
|
||||
|
||||
<style-line name="building" stroke="#c9c3c1" width="1.2" fixed="true" cap="butt" fade="15"/>
|
||||
<style-area name="building" fill="#e9e6e3" fade="15"/>
|
||||
|
||||
<!-- ways -->
|
||||
<rule e="way" k="*" v="*" >
|
||||
|
||||
<rule e="way" k="natural" v="grassland|scrub" zoom-min="10">
|
||||
<use-area name="greens"/>
|
||||
</rule>
|
||||
|
||||
<!-- landuse base -->
|
||||
<rule e="way" k="landuse" v="*">
|
||||
|
||||
<rule e="way" k="*" zoom-min="10" v="farmland|farm|orchard|vineyard|greenhouse_horticulture|plant_nursery">
|
||||
<use-area name="farmland"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="quarry">
|
||||
<use-area name="quarry"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="residential|farmyard|retail|commercial|industrial;retail">
|
||||
<use-area name="residential" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="industrial|railway">
|
||||
<use-area name ="railway|industrial"/>
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="military">
|
||||
<use-area name="military"/>
|
||||
</rule> -->
|
||||
|
||||
<!--<rule e="way" k="landuse" v="construction|greenfield"> <area fill="#a47c41"
|
||||
stroke="#e4e4e4" width="0.2" /> </rule> -->
|
||||
<!-- <rule e="way" k="landuse" v="garages"> <area fill="#d6d6e4" /> </rule> -->
|
||||
</rule>
|
||||
|
||||
|
||||
|
||||
<rule e="way" k="landuse|natural|leisure||amenity" v="*">
|
||||
<!-- kind of more like landuse imho -->
|
||||
<rule e="way" k="leisure|landuse" v="nature_reserve">
|
||||
<use-area name="greens2" />
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<line stroke="#abe29c" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- landuse -->
|
||||
<rule e="way" k="landuse" v="*" zoom-min="11">
|
||||
<!-- how about 'leisure' for this one? -->
|
||||
<rule e="way" k="*" v="cemetery">
|
||||
<use-area name="park"/>
|
||||
</rule>
|
||||
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="landuse" v="village_green|recreation_ground" >
|
||||
<use-area name="greens" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="landuse" v="allotments" zoom-min="12">
|
||||
<use-area name="allotments"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="leisure" v="park|common|green|golf_course|dog_park" zoom-min="11">
|
||||
<use-area name="park"/>
|
||||
</rule>
|
||||
|
||||
<!-- Heideland, keep below forest -->
|
||||
<rule e="way" k="*" zoom-min="11" v="heath|sand">
|
||||
<area fill="#ffffc0" fade="11" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="landuse" v="forest">
|
||||
<use-area name="forest|wood"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="natural" v="wood">
|
||||
<use-area name="forest|wood"/>
|
||||
<!-- <line stroke="#abcfab" width="1.5" fixed="true" cap="butt"/> -->
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- keep grass above forest:wood and leisure:park! -->
|
||||
<rule e="way" k="landuse" v="grass|meadow">
|
||||
<use-area name="greens"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="leisure" v="garden">
|
||||
<use-area name="greens"/>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule e="way" k="leisure" v="track">
|
||||
<line stroke="#c1bcb6" width="1.3" cap="butt" fixed="true" />
|
||||
</rule>
|
||||
|
||||
<!-- amenity -->
|
||||
<rule e="way" k="amenity" v="*">
|
||||
<rule e="way" k="*" v="kindergarten|school|college|university" zoom-min="14">
|
||||
<area fill="#cdabde" />
|
||||
<line stroke="#9aabae" width="1.0" fixed="true" cap="butt"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="parking" zoom-min="14">
|
||||
<area fill="#f4f4f4" stroke="#d4d4d4" stroke-width="0.2" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="fountain" closed="yes">
|
||||
<area fill="#b4cbdc" stroke="#000080" stroke-width="0.15" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="natural" v="coastline">
|
||||
<line stroke="#a4bbcc" width="1.2" fixed="true" />
|
||||
</rule> -->
|
||||
|
||||
<!-- natural -->
|
||||
<rule e="way" k="natural" v="*" zoom-min="10">
|
||||
|
||||
<rule e="way" k="*" v="glacier">
|
||||
<area fill="#fafaff" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="land">
|
||||
<area fill="#f8f8f8" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="beach">
|
||||
<area fill="#fcfeab" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="marsh|wetland|mud">
|
||||
<use-area name="greens2" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- leisure -->
|
||||
<rule e="way" k="leisure" v="*" zoom-min="13">
|
||||
|
||||
<rule e="way" k="*" v="stadium" >
|
||||
<line stroke="#c9c3c1" width="1.0" fixed="true" cap="butt" />
|
||||
<area fill="#e9e6e3" />
|
||||
</rule>
|
||||
|
||||
<!--should be under playing field -->
|
||||
<rule e="way" k="*" zoom-min="14" v="sports_centre|water_park">
|
||||
<area fill="#daefdb" fade="12" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" zoom-min="15" v="playground|miniature_golf">
|
||||
<area fill="#f4f4de" />
|
||||
<line stroke="#fbdbc8" width="0.6" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="playing_fields|pitch">
|
||||
<area fill="#f4f4de" />
|
||||
<line stroke="#dbdbc8" width="0.6" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="swimming_pool">
|
||||
<area fill="#b4cbdc" stroke="#6060ff" width="0.2" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="track"> <rule e="way" k="area" v="yes|true">
|
||||
<area fill="#c9d8a2" stroke="#b7c690" width="0.025" /> </rule> <rule
|
||||
e="way" k="area" v="~|no|false"> <line stroke="#b7c690" width="0.75"
|
||||
/> </rule> </rule> -->
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- area outlines need to be above to avoid uggly pixelation where
|
||||
not aliased polygon overlaps the lines... -->
|
||||
|
||||
<rule e="way" k="leisure|landuse" v="*" zoom-min="14">
|
||||
|
||||
<rule e="way" k="*" v="nature_reserve">
|
||||
<line stroke="#abe29c" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="military">
|
||||
<use-line name="fence" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule e="way" k="natural" v="water">
|
||||
<use-area name="water"/>
|
||||
<use-line name="water:outline"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="landuse" v="reservoir|basin">
|
||||
<use-area name="water" />
|
||||
</rule>
|
||||
|
||||
<!-- waterways -->
|
||||
<rule e="way" k="waterway" v="*">
|
||||
|
||||
<rule e="way" k="waterway" v="ditch|drain" zoom-min="14">
|
||||
<use-line name="water" width="0.1" fixed="true"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="canal">
|
||||
<use-line name="water" width="-0.2"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="stream" zoom-min="14">
|
||||
<use-line name="water" width="-0.7"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="river">
|
||||
<rule e="way" k="*" v="*" zoom-min="12">
|
||||
<use-line name="water" width="0.3"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="*" zoom-max="11">
|
||||
<use-line name="water" width="0.3" fixed="true"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="riverbank|dock">
|
||||
<use-area name="water"/>
|
||||
<use-line name="water:outline"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="weir">
|
||||
<line stroke="#000044" width="0.375" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="dam" zoom-min="12">
|
||||
<!-- sehr seltsam was in deutschland so als Damm gekenzeichnet wird.. -->
|
||||
<line stroke="#ababab" width="1.2" cap="butt" fixed="true" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="lock" v="yes|true">
|
||||
<line stroke="#f8f8f8" width="1.5" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- sport -->
|
||||
<!-- <rule e="way" k="sport" v="*"> <rule e="way" k="sport" v="soccer"
|
||||
zoom-min="17"> <rule e="way" k="sport" v="swimming|canoe|diving|scuba_diving">
|
||||
<area fill="#b4cbdc" stroke="#6060ff" width="0.2" /> </rule> <rule
|
||||
e="way" k="sport" v="tennis"> <area fill="#d18a6a" stroke="#b36c4c" width="0.2"
|
||||
/> </rule> </rule> -->
|
||||
|
||||
<!-- tourism areas -->
|
||||
<rule e="way" k="tourism" v="*">
|
||||
<!-- <rule e="way" k="tourism" v="attraction"> <area fill="#f2caea" /> </rule> -->
|
||||
|
||||
<rule e="way" k="tourism" v="zoo|picnic_site|caravan_site|camp_site">
|
||||
<area fill="#d7e6b0" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
|
||||
<!-- outline 0 -->
|
||||
<style-outline name="glow" stroke="#000000" width="0.2" blur="1.0"/>
|
||||
|
||||
<style-outline name="0" stroke="#44000000" width="0.1" />
|
||||
<!-- tunnel -->
|
||||
<rule e="way" k="tunnel" v="yes|true" zoom-min="11">
|
||||
<!-- highway tunnels -->
|
||||
<rule e="way" k="highway" v="*">
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<rule e="way" k="*" v="steps">
|
||||
<use-line name="steps"/>
|
||||
<use-outline name="0"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="16">
|
||||
<use-line name="footway:z16"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="15">
|
||||
<use-line name="footway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="bridleway">
|
||||
<use-line name="bridleway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="construction">
|
||||
<use-line name="construction"/>
|
||||
<use-outline name="0"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="service">
|
||||
<rule e="way" k="service" v="~|parking_aisle">
|
||||
<use-line name="highway-service"/>
|
||||
<use-outline name="0"/>
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link">
|
||||
<use-line name="trunk_link"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="13">
|
||||
<rule e="way" k="*" v="byway|pedestrian">
|
||||
<use-line name="pedestrian"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule e="way" k="*" v="residential|road|unclassified|living_street">
|
||||
<use-line name="residential"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="tertiary|secondary_link">
|
||||
<use-line name="tertiary"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="secondary|primary_link">
|
||||
<use-line name="secondary:z11"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary">
|
||||
<use-line name="primary:z11"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk">
|
||||
<use-line name="trunk" blur="0.3"/>
|
||||
<use-outline name="0"/>
|
||||
<!-- <use-outline name="glow"/> -->
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<use-line name="highway:z11" blur="0.3"/>
|
||||
<use-outline name="0"/>
|
||||
<!-- <use-outline name="glow"/> -->
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- railway tunnel -->
|
||||
<rule e="way" k="railway" v="*">
|
||||
<!-- <rule e="way" k="railway" v="tram|subway|light_rail|narrow_gauge">
|
||||
<line stroke="#a0a0a0" width="0.8" cap="butt" fixed="true"/>
|
||||
</rule> -->
|
||||
<rule e="way" k="railway" v="rail">
|
||||
<line stroke="#aa888888" width="0.9" cap="butt" fixed="true" />
|
||||
</rule>
|
||||
</rule>
|
||||
</rule> <!-- end tunnel -->
|
||||
|
||||
|
||||
<!-- platform cores -->
|
||||
<rule e="way" k="highway|railway|public_transport" v="platform">
|
||||
<rule e="way" k="*" v="*" closed="yes">
|
||||
<area fill="#dbdbc9" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="*" closed="no">
|
||||
<line stroke="#dbdbc9" width="0.3" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- runways areas -->
|
||||
<rule e="way" k="aeroway" v="*">
|
||||
<rule e="way" k="*" v="aerodrome" closed="yes">
|
||||
<area fill="#e8ecde" />
|
||||
</rule>
|
||||
<!-- A place where planes are parked -->
|
||||
<rule e="way" k="*" v="apron">
|
||||
<area fill="#f0f0f0" />
|
||||
</rule>
|
||||
<!-- Airport passenger building -->
|
||||
<rule e="way" k="*" v="terminal|hangar">
|
||||
<use-line name="building" />
|
||||
<use-area name="building" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- turning circles -->
|
||||
<!-- <rule e="node" k="highway" v="turning_circle"> <circle r="1.5" scale-radius="true"
|
||||
fill="#707070" />
|
||||
</rule> -->
|
||||
|
||||
<!-- building -->
|
||||
<rule e="way" k="building" v="*">
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<use-area name="building" fade="15"/>
|
||||
<use-line name="building" fade="15"/>
|
||||
<!-- <line stroke="#c9c3c1" width="1.0" fixed="true" cap="butt" fade="15"/>
|
||||
<area fill="#e9e6e3" fade="15" /> -->
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="*" zoom-min="17">
|
||||
<caption k="name" font-style="bold" font-size="10" fill="#4040ff"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
<caption k="addr:housenumber" font-style="bold" font-size="10" fill="#606060"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule> -->
|
||||
</rule>
|
||||
|
||||
<!-- outline 1 - 4 -->
|
||||
<style-outline name="1" stroke="#ee605020" width="0.02"/>
|
||||
<!-- <style-outline name="1" stroke="#404030"/> -->
|
||||
<style-outline name="2" stroke="#c0c0c0" />
|
||||
<style-outline name="primary" stroke="#7f7700" width="0.025"/>
|
||||
<style-outline name="motorway" stroke="#805f2e" width="0.025"/>
|
||||
|
||||
|
||||
<!-- highway -->
|
||||
<rule e="way" k="highway" v="*">
|
||||
<rule e="way" k="*" v="*" zoom-min="5" zoom-max="10">
|
||||
<rule e="way" k="area" v="~|no|false">
|
||||
<rule e="way" k="*" v="secondary|primary_link" zoom-min="9">
|
||||
<line stroke="#f2df6d" width="1.8" cap="butt" fixed="true" fade="9"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link" zoom-min="8">
|
||||
<line stroke="#fed6a3" width="1.8" cap="butt" fixed="true" fade="8"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary" zoom-min="5">
|
||||
<line stroke="#f2df6d" width="1.8" cap="butt" fixed="true" fade="5"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk" zoom-min="5">
|
||||
<line stroke="#fed6a3" width="2.0" cap="butt" fixed="true" fade="5"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<line stroke="#eec693" width="2.2" cap="butt" fixed="true" fade="5"/>
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="11">
|
||||
<rule e="way" k="tunnel|bridge" v="~|no|false">
|
||||
<!-- highway area -->
|
||||
<rule e="way" k="area" v="yes|true">
|
||||
<rule e="way" k="tunnel|bridge" v="~|no|false">
|
||||
<rule e="way" k="*" v="footway" zoom-min="15">
|
||||
<area fill="#fefefe" />
|
||||
<line stroke="#c0c0c0" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" zoom-min="13" v="pedestrian|service|unclassified|residential|road|living_street">
|
||||
<area fill="#ffffff" />
|
||||
<line stroke="#d0d0d0" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="path" zoom-min="14">
|
||||
<area fill="#d0d0d0" />
|
||||
</rule>-->
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="area" v="~|no|false">
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<rule e="way" k="*" v="steps">
|
||||
<use-line name="steps"/>
|
||||
<use-outline name="2"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="16" zoom-max="16">
|
||||
<use-line name="footway:z16"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="17">
|
||||
<use-line name="footway:z17"/>
|
||||
<use-outline name="1"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="15">
|
||||
<use-line name="footway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="bridleway">
|
||||
<use-line name="bridleway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="construction">
|
||||
<use-line name="construction"/>
|
||||
<use-outline name="1"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="service">
|
||||
<rule e="way" k="service" v="-|parking_aisle">
|
||||
<use-line name="highway-service"/>
|
||||
<use-outline name="1"/>
|
||||
</rule>
|
||||
<rule e="way" k="service" v="parking_aisle" zoom-min="16">
|
||||
<use-line name="highway-service" width="-0.4"/>
|
||||
<use-outline name="1"/>
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link">
|
||||
<use-line name="trunk_link"/>
|
||||
<use-outline name="motorway"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="13">
|
||||
<rule e="way" k="*" v="byway|pedestrian">
|
||||
<use-line name="residential" width="-0.4"/>
|
||||
<use-outline name="1"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="residential|road|unclassified|living_street">
|
||||
<use-line name="residential"/>
|
||||
<use-outline name="1"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="tertiary|secondary_link">
|
||||
<use-line name="tertiary"/>
|
||||
<use-outline name="1"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="secondary|primary_link">
|
||||
<!-- <line stroke="#fff939" width="1.6" /> -->
|
||||
<use-line name="secondary:z11"/>
|
||||
<use-outline name="primary"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary">
|
||||
<use-line name="primary:z11"/>
|
||||
<use-outline name="primary"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk">
|
||||
<use-line name="trunk"/>
|
||||
<use-outline name="motorway"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<use-line name="highway:z11"/>
|
||||
<use-outline name="motorway"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
</rule> <!-- end area=~|no|false -->
|
||||
</rule> <!-- end tunnel|bridge=~|no|false -->
|
||||
|
||||
|
||||
<rule e="way" k="bridge" v="yes|true|viaduct|suspension">
|
||||
<rule e="way" k="area" v="~|no|false">
|
||||
|
||||
<style-outline name="bridge" stroke="#aa202020" width="0.08"/>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<rule e="way" k="*" v="steps">
|
||||
<use-line name="steps"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="16" zoom-max="16">
|
||||
<use-line name="footway:z16"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="17">
|
||||
<use-line name="footway:z17" cap="butt"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="15">
|
||||
<use-line name="footway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="bridleway">
|
||||
<use-line name="bridleway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="construction">
|
||||
<use-line name="construction" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="service">
|
||||
<use-line name="highway-service" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="13">
|
||||
<rule e="way" k="*" v="byway|pedestrian">
|
||||
<use-line name="pedestrian:bridge"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="residential|road|unclassified|living_street">
|
||||
<use-line name="residential:bridge"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="tertiary|secondary_link">
|
||||
<use-line name="tertiary" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link">
|
||||
<use-line name="trunk_link" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="secondary|primary_link">
|
||||
<!-- <line stroke="#fff939" width="1.6" cap="butt" /> -->
|
||||
<use-line name="secondary:z11" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary">
|
||||
<use-line name="primary:z11" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk">
|
||||
<use-line name="trunk" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<use-line name="highway:z11" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
</rule> <!-- end area=~|no|false -->
|
||||
|
||||
<rule e="way" k="area" v="yes|true">
|
||||
<rule e="way" k="*" v="footway" zoom-min="15">
|
||||
<area fill="#fefefe" />
|
||||
<line stroke="#c0c0c0" width="0.15" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" zoom-min="13" v="pedestrian|service|unclassified|residential|road|living_street">
|
||||
<area fill="#ffffff" />
|
||||
<line stroke="#d0d0d0" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="path" zoom-min="14">
|
||||
<area fill="#d0d0d0" />
|
||||
</rule>-->
|
||||
</rule> <!-- end area=yes|true -->
|
||||
</rule> <!-- end bridge=yes -->
|
||||
</rule> <!-- end zoom-min=11 -->
|
||||
</rule> <!-- end highway -->
|
||||
|
||||
|
||||
<!-- runways cores -->
|
||||
<rule e="way" k="aeroway" v="*">
|
||||
<rule e="way" k="*" v="runway">
|
||||
<use-line name="aeroway:runway"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="taxiway">
|
||||
<use-line name="aeroway:runway" width="-0.8"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- man_made features -->
|
||||
<!-- <rule e="way" k="man_made" v="pier">
|
||||
<rule e="way" k="*" v="*" closed="no">
|
||||
<line stroke="#d0d0d0" width="0.4" cap="butt" />
|
||||
<line stroke="#e4e4e4" width="0.3" cap="butt" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="*" closed="yes">
|
||||
<area fill="#e4e4e4" stroke="#d0d0d0" stroke-width="0.05" />
|
||||
</rule>
|
||||
</rule> -->
|
||||
|
||||
|
||||
<!-- barriers -->
|
||||
<rule e="way" k="barrier" v="*">
|
||||
<!-- <rule e="way" k="*" v="fence|wall|city_wall" zoom-min="15"> <line
|
||||
stroke="#909090" width="0.1" cap="butt" /> </rule> -->
|
||||
<rule e="way" k="*" v="retaining_wall" zoom-min="15">
|
||||
<line stroke="#888888" width="0.1" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- non-physical routes -->
|
||||
<!-- <rule e="way" k="route" v="ferry"> <line stroke="#707070" width="0.3"
|
||||
stroke-dasharray="15,10" cap="butt" /> </rule> -->
|
||||
|
||||
<!-- aerial ways -->
|
||||
<!-- <rule e="way" k="aerialway" v="*"> <line stroke="#202020" width="0.4"
|
||||
cap="butt" /> <rule e="way" k="aerialway" v="cable_car"> <lineSymbol
|
||||
src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/cable_car.png"
|
||||
/> </rule> <rule e="way" k="aerialway" v="chair_lift"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/chair_lift_2.png"
|
||||
/> </rule> <rule e="way" k="aerialway" v="gondola"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/gondola.png"
|
||||
/> </rule> <rule e="way" k="*" v="*" zoom-min="14"> <pathText k="name" font-style="bold"
|
||||
font-size="10" fill="#606060" stroke="#ffffff" width="2.0" /> </rule>
|
||||
</rule> -->
|
||||
|
||||
|
||||
<!-- railway (no tunnel) -->
|
||||
<rule e="way" k="railway" v="*" zoom-min="12">
|
||||
<rule e="way" k="tunnel" v="~|false|no">
|
||||
|
||||
<rule e="way" k="railway" v="station">
|
||||
<area fill="#dbdbc9" stroke="#707070" stroke-width="0.3" />
|
||||
</rule>
|
||||
|
||||
<!-- railway bridge casings -->
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="bridge" v="yes|true">
|
||||
<rule e="way" k="railway" v="tram">
|
||||
<line stroke="#777777" width="0.9" cap="butt"
|
||||
fixed="true" />
|
||||
</rule>
|
||||
<rule e="way" k="railway" v="subway|light_rail|narrow_gauge">
|
||||
<line stroke="#777777" width="0.9" cap="butt"
|
||||
fixed="true" />
|
||||
</rule>
|
||||
<rule e="way" k="railway" v="rail">
|
||||
<line stroke="#777777" width="0.9" cap="butt"
|
||||
fixed="true" />
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- railway casings and cores -->
|
||||
<rule e="way" k="railway" v="tram" zoom-min="15">
|
||||
<line stroke="#887766" width="1.0" fixed="true" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="railway" v="light_rail|subway|narrow_gauge" zoom-min="14">
|
||||
<line stroke="#a0a0a0" width="0.9" cap="butt" fixed="true" />
|
||||
|
||||
</rule>
|
||||
<rule e="way" k="railway" v="rail|turntable" >
|
||||
<line stroke="#887766" width="0.8" cap="butt" fixed="true" fade="12"/>
|
||||
</rule>
|
||||
<!-- <rule e="way" k="railway" v="rail" zoom-max="14" zoom-min="13">
|
||||
<line stroke="#8888aa" width="0.6" cap="butt"
|
||||
fixed="true" />
|
||||
</rule> -->
|
||||
<!-- <rule e="way" k="railway" v="rail" zoom-max="13" zoom-min="11">
|
||||
<line stroke="#bbbbcc" width="0.8" cap="butt" fixed="true" />
|
||||
</rule> -->
|
||||
<!-- whatever railway:spur means ... -->
|
||||
<rule e="way" k="railway" v="disused|spur|abandoned|preserved" >
|
||||
<line stroke="#cccccc" width="0.8" cap="butt" fixed="true" fade="12"/>
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- non-physical boundaries -->
|
||||
<!-- <rule e="way" k="boundary" v="*"> <rule e="way" k="boundary" v="national_park">
|
||||
<line stroke="#4ef94b" width="0.25" stroke-dasharray="15, 5, 5, 5"
|
||||
/> -->
|
||||
|
||||
<!--<rule e="way" k="boundary" v="administrative"> -->
|
||||
<rule e="way" k="admin_level" v="*">
|
||||
<!-- <rule e="way" k="admin_level" v="11"> <line stroke="#f9574b" width="0.1"
|
||||
fixed="true" cap="butt" /> </rule> <rule e="way" k="admin_level"
|
||||
v="10"> <line stroke="#f9574b" width="0.1" fixed="true" cap="butt"
|
||||
/> </rule> <rule e="way" k="admin_level" v="9"> <line stroke="#f9574b" width="0.1"
|
||||
fixed="true" cap="butt" /> </rule> <rule e="way" k="admin_level"
|
||||
v="8"> <line stroke="#f9574b" width="0.3" fixed="true" cap="butt"
|
||||
/> </rule> <rule e="way" k="admin_level" v="7"> <line stroke="#f9574b" width="0.1"
|
||||
fixed="true" cap="butt" /> </rule> <rule e="way" k="admin_level"
|
||||
v="6"> <line stroke="#f9574b" width="0.15" fixed="true" cap="butt"
|
||||
/> </rule> <rule e="way" k="admin_level" v="5"> <line stroke="#f9574b" width="0.15"
|
||||
fixed="true" cap="butt" /> </rule> -->
|
||||
<rule e="way" k="admin_level" v="4">
|
||||
<line stroke="#8f80dd" width="0.9" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
<rule e="way" k="admin_level" v="3">
|
||||
<line stroke="#0000ff" width="0.95" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
<rule e="way" k="admin_level" v="2">
|
||||
<line stroke="#a0a0a0" width="0.95" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
<rule e="way" k="admin_level" v="1">
|
||||
<line stroke="#ff0000" width="0.95" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
</rule>
|
||||
<!-- </rule> -->
|
||||
|
||||
|
||||
<!-- historic -->
|
||||
<!-- <rule e="way" k="historic" v="ruins" zoom-min="17">
|
||||
<caption k="name" font-style="bold" font-size="10" fill="#4040ff" stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule> -->
|
||||
|
||||
<!-- place -->
|
||||
<rule e="way" k="place" v="locality" zoom-min="17">
|
||||
<caption k="name" font-style="bold" font-size="10" fill="#000000" stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule>
|
||||
<rule e="way" k="debug" v="area">
|
||||
<line stroke="#ff0000" width="1.2" fixed="true" cap="butt" />
|
||||
<area fill="#880000ff"/>
|
||||
<caption k="name" font-size="15" fill="#ff0000" stroke="#444444" stroke-width="2.0"/>
|
||||
</rule>
|
||||
<rule e="way" k="debug" v="way">
|
||||
<line stroke="#00ffff" width="1.5" fixed="true" cap="butt" />
|
||||
<caption k="name" font-size="15" fill="#00ffff" stroke="#444444" stroke-width="2.0"/>
|
||||
</rule>
|
||||
<rule e="way" k="debug" v="box">
|
||||
<line stroke="#000000" width="1.5" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="node" k="*" v="*">
|
||||
<!-- barrier -->
|
||||
<rule e="node" k="barrier" v="bollard">
|
||||
<circle r="1.5" fill="#909090" />
|
||||
</rule>
|
||||
|
||||
<rule e="node" k="debug" v="*" >
|
||||
<caption k="name" font-size="12" fill="#0000ff" />
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- highway -->
|
||||
<!-- <rule e="node" k="highway" v="*"> <rule e="node" k="highway" v="turning_circle">
|
||||
<circle r="1.4" scale-radius="true" fill="#ffffff" /> </rule> </rule> -->
|
||||
|
||||
<!-- historic -->
|
||||
<!-- <rule e="node" k="historic" v="*"> <circle r="3" fill="#4040ff" stroke="#606060"
|
||||
width="1.5" /> <rule e="node" k="*" v="*" zoom-min="17"> <caption
|
||||
k="name" dy="-10" font-style="bold" font-size="10" fill="#4040ff" stroke="#ffffff"
|
||||
width="2.0" /> </rule> </rule> -->
|
||||
|
||||
|
||||
<!-- house numbers -->
|
||||
<!-- <rule e="node" k="addr:housenumber" v="*" zoom-min="18"> <caption
|
||||
k="addr:housenumber" font-style="bold" font-size="10" fill="#606060" stroke="#ffffff"
|
||||
width="2.0" /> </rule> -->
|
||||
|
||||
|
||||
|
||||
<!-- place -->
|
||||
<rule e="node" k="place" v="*">
|
||||
<rule e="node" k="*" v="suburb|town|village">
|
||||
<caption k="name" font-size="18" fill="#000000"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule>
|
||||
<rule e="node" k="*" v="island" zoom-min="10">
|
||||
<caption k="name" font-style="bold" font-size="20" fill="#000000"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule>
|
||||
<rule e="node" k="*" v="city">
|
||||
<caption k="name" font-style="bold" font-size="20" fill="#000000"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule>
|
||||
<rule e="node" k="*" v="country">
|
||||
<caption k="name" font-size="20" fill="#000000"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- railway -->
|
||||
<rule e="node" k="railway" v="*">
|
||||
<rule e="node" k="*" v="station" zoom-min="14">
|
||||
<circle r="6" fill="#ec2d2d" stroke="#606060" width="1.5" />
|
||||
<!-- <caption k="name" dy="-10" font-style="bold" font-size="13" fill="#ec2d2d"
|
||||
stroke="#ffffff" stroke-width="2.0" /> -->
|
||||
</rule>
|
||||
<rule e="node" k="*" v="halt|tram_stop" zoom-min="17">
|
||||
<circle r="4" fill="#ec2d2d" stroke="#606060" width="1.5" />
|
||||
<!-- <caption k="name" dy="-15" font-style="bold" font-size="11" fill="#ec2d2d"
|
||||
stroke="#ffffff" stroke-width="2.0" /> -->
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
</rendertheme>
|
||||
992
src/org/oscim/theme/osmarender/tronrender.xml
Normal file
992
src/org/oscim/theme/osmarender/tronrender.xml
Normal file
@@ -0,0 +1,992 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rendertheme xmlns="http://mapsforge.org/renderTheme"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://mapsforge.org/renderTheme ../renderTheme.xsd"
|
||||
version="1" map-background="#050508">
|
||||
|
||||
<style-pathtext name="road" k="name" font-style="bold" font-size="18" stroke="#606050" fill="#eeffee" stroke-width="2.5" />
|
||||
<style-pathtext name="major-road" k="name" font-style="bold" font-size="19" fill="#e2cf5d" stroke="#101010" stroke-width="2.5" />
|
||||
|
||||
<style-area name="residential" fill="#ff0000" fade="10"/>
|
||||
|
||||
<style-area name="railway|industrial" fill="#f2eeef" fade="10"/>
|
||||
<!-- "#f0fae7" mint green -->
|
||||
<style-area name="farmland" fill="#fff8bf" fade="11" />
|
||||
|
||||
<!-- fade out at z=7, blend over to 'blend-fill' in z=11 -->
|
||||
<style-area name="forest|wood" fill="#151806" fade="7" blend="11" blend-fill="#1e2205"/>
|
||||
|
||||
<!-- grass|meadow|garden|grassland|scrub -->
|
||||
<style-area name="greens" fill="#33390c" fade="10" />
|
||||
|
||||
<!-- marsh|wetland|nature_reserve -->
|
||||
<style-area name="greens2" fill="#627100" fade="12" />
|
||||
|
||||
<!-- park|common|green|cemetery|golf_course|dog_park -->
|
||||
<style-area name="park" fill="#627100" fade="11" />
|
||||
|
||||
<!-- de:Kleingartengebiet -->
|
||||
<style-area name="allotments" fill="#efeae0" fade="12" />
|
||||
|
||||
<!-- de:Steinbruch, Schotter-, Kies-, Sand- und Tongrube -->
|
||||
<style-area name="quarry" fill="#ddddcc" fade="10" />
|
||||
|
||||
<style-area name="military" fill="#eeedea" fade="10"/>
|
||||
|
||||
|
||||
<style-line name="residential" stroke="#ffffff" width="1.0" blur="1.0" fade="13"/>
|
||||
<style-line name="residential:bridge" from="residential" cap="square"/>
|
||||
|
||||
<!-- when inheriting another style with 'from' then 'witdth' is meant relative to the parent -->
|
||||
<style-line name="pedestrian" from="residential" width="-0.4"/>
|
||||
<style-line name="pedestrian:bridge" from="pedestrian" cap="square"/>
|
||||
|
||||
<style-line name="highway:z11" stroke="#fcba5a" width="1.8" blur="0.9"/>
|
||||
<!-- <style-line name="highway:z11:bridge" from="highway:z11" cap="butt" /> -->
|
||||
|
||||
<style-line name="trunk_link" stroke="#fee16e" width="1.3" cap="butt" blur="0.9"/>
|
||||
<style-line name="trunk" stroke="#fedb52" width="1.6" blur="0.9"/>
|
||||
<style-line name="primary:z11" stroke="#f2df6d" width="1.5" blur="0.9"/>
|
||||
<style-line name="secondary:z11" from="primary:z11" width="-0.1"/>
|
||||
|
||||
<style-line name="tertiary" from="residential" width="0.2" fade="11"/>
|
||||
<style-line name="construction" stroke="#e0e0e0" width="1.2" />
|
||||
|
||||
<style-line name="highway-service" from="residential" width="-0.6" />
|
||||
|
||||
<!-- track|footway|path|cycleway -->
|
||||
<style-line name="footway" stroke="#c1bcb6" width="1.2" cap="butt" fixed="true"/>
|
||||
<style-line name="footway:z16" from="footway" width="-1.0" fixed="false" fade="-1"/>
|
||||
<style-line name="footway:z17" stroke="#faf8f5" width="0.3"/>
|
||||
|
||||
<!-- de: ein Weg der für Reiter vorgeshen ist.. -->
|
||||
<style-line name="bridleway" stroke="#d3cb98" width="0.4" cap="butt"/>
|
||||
|
||||
<style-line name="steps" stroke="#f1f0f4" width="0.25" cap="butt" />
|
||||
|
||||
<style-line name="water:outline" stroke="#a4bbcc" width="1.0" cap="butt" />
|
||||
<style-line name="water" stroke="#cca4bbcc" width="0.6" cap="butt" />
|
||||
<style-area name="water" fill="#001223" />
|
||||
<!-- no-go area boundary -->
|
||||
<style-line name="fence" stroke="#444444" width="1.2" fixed="true" cap="butt"/>
|
||||
|
||||
<style-line name="aeroway:runway" stroke="#008888" width="1.8" cap="butt" blur="0.7" />
|
||||
|
||||
<style-line name="building" stroke="#dd999999" width="1.8" fixed="true" cap="butt"/>
|
||||
<style-area name="building" fill="#ee202020" fade="15"/>
|
||||
|
||||
<!-- ways -->
|
||||
<rule e="way" k="*" v="*" >
|
||||
|
||||
<rule e="way" k="natural" v="grassland|scrub" zoom-min="10">
|
||||
<use-area name="greens"/>
|
||||
</rule>
|
||||
|
||||
<!-- landuse base -->
|
||||
<rule e="way" k="landuse" v="*">
|
||||
|
||||
<!-- <rule e="way" k="*" zoom-min="10" v="farmland|farm|orchard|vineyard|greenhouse_horticulture|plant_nursery">
|
||||
<use-area name="farmland"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="quarry">
|
||||
<use-area name="quarry"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="residential|farmyard|retail|commercial|industrial;retail">
|
||||
<use-area name="residential" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="industrial|railway">
|
||||
<use-area name ="railway|industrial"/>
|
||||
</rule>
|
||||
-->
|
||||
<!-- <rule e="way" k="*" v="military">
|
||||
<use-area name="military"/>
|
||||
</rule> -->
|
||||
|
||||
<!--<rule e="way" k="landuse" v="construction|greenfield"> <area fill="#a47c41"
|
||||
stroke="#e4e4e4" width="0.2" /> </rule> -->
|
||||
<!-- <rule e="way" k="landuse" v="garages"> <area fill="#d6d6e4" /> </rule> -->
|
||||
</rule>
|
||||
|
||||
|
||||
|
||||
<rule e="way" k="landuse|natural|leisure||amenity" v="*">
|
||||
<!-- kind of more like landuse imho -->
|
||||
<rule e="way" k="leisure|landuse" v="nature_reserve">
|
||||
<use-area name="greens2" />
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<line stroke="#abe29c" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- landuse -->
|
||||
<rule e="way" k="landuse" v="*" zoom-min="11">
|
||||
<!-- how about 'leisure' for this one? -->
|
||||
<rule e="way" k="*" v="cemetery">
|
||||
<use-area name="park"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="reservoir|basin">
|
||||
<use-area name="water" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="landuse" v="village_green|recreation_ground" >
|
||||
<use-area name="greens" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="landuse" v="allotments" zoom-min="12">
|
||||
<use-area name="allotments"/>
|
||||
</rule>-->
|
||||
|
||||
<rule e="way" k="leisure" v="park|common|green|golf_course|dog_park" zoom-min="11">
|
||||
<use-area name="park"/>
|
||||
</rule>
|
||||
|
||||
<!-- Heideland, keep below forest -->
|
||||
<rule e="way" k="*" zoom-min="11" v="heath|sand">
|
||||
<area fill="#0f0f0c" fade="11" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="landuse" v="forest">
|
||||
<use-area name="forest|wood"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="natural" v="wood">
|
||||
<use-area name="forest|wood"/>
|
||||
<!-- <line stroke="#abcfab" width="1.5" fixed="true" cap="butt"/> -->
|
||||
</rule>
|
||||
|
||||
<!-- keep grass above forest:wood and leisure:park! -->
|
||||
<rule e="way" k="landuse" v="grass|meadow">
|
||||
<use-area name="greens"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="leisure" v="garden">
|
||||
<use-area name="greens"/>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule e="way" k="leisure" v="track">
|
||||
<line stroke="#c1bcb6" width="1.3" cap="butt" fixed="true" />
|
||||
</rule>
|
||||
|
||||
<!-- amenity -->
|
||||
<rule e="way" k="amenity" v="*">
|
||||
<rule e="way" k="*" v="kindergarten|school|college|university" zoom-min="14">
|
||||
<area fill="#cdabde" stroke="#b094bf" stroke-width="0.2" /> </rule>
|
||||
|
||||
<rule e="way" k="*" v="parking" zoom-min="14">
|
||||
<area fill="#f4f4f4" stroke="#d4d4d4" stroke-width="0.2" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="fountain" closed="yes">
|
||||
<area fill="#b4cbdc" stroke="#000080" stroke-width="0.15" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="natural" v="coastline">
|
||||
<line stroke="#a4bbcc" width="1.2" fixed="true" />
|
||||
</rule> -->
|
||||
|
||||
<!-- natural -->
|
||||
<rule e="way" k="natural" v="*" zoom-min="10">
|
||||
|
||||
<rule e="way" k="*" v="glacier">
|
||||
<area fill="#fafaff" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="land">
|
||||
<area fill="#080808" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="beach">
|
||||
<area fill="#aaedd400"/>
|
||||
<line stroke="#fce94f" fixed="true" width="2.8" />
|
||||
</rule>-->
|
||||
|
||||
<rule e="way" k="*" v="marsh|wetland|mud">
|
||||
<use-area name="greens2" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- leisure -->
|
||||
<rule e="way" k="leisure" v="*" zoom-min="13">
|
||||
|
||||
<rule e="way" k="*" v="stadium" >
|
||||
<area fill="#404040" />
|
||||
<line stroke="#cccccc" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<!--should be under playing field -->
|
||||
<!-- <rule e="way" k="*" zoom-min="14" v="sports_centre|water_park">
|
||||
<area fill="#daefdb" fade="12" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" zoom-min="15" v="playground|miniature_golf">
|
||||
<area fill="#f4f4de" />
|
||||
<line stroke="#fbdbc8" width="0.6" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="playing_fields|pitch">
|
||||
<area fill="#f4f4de" />
|
||||
<line stroke="#dbdbc8" width="0.6" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
-->
|
||||
<rule e="way" k="*" v="swimming_pool">
|
||||
<area fill="#b4cbdc" stroke="#6060ff" width="0.2" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="track"> <rule e="way" k="area" v="yes|true">
|
||||
<area fill="#c9d8a2" stroke="#b7c690" width="0.025" /> </rule> <rule
|
||||
e="way" k="area" v="~|no|false"> <line stroke="#b7c690" width="0.75"
|
||||
/> </rule> </rule> -->
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- area outlines need to be above to avoid uggly pixelation where
|
||||
not aliased polygon overlaps the lines... -->
|
||||
|
||||
<rule e="way" k="leisure|landuse" v="*" zoom-min="14">
|
||||
|
||||
<rule e="way" k="*" v="nature_reserve">
|
||||
<line stroke="#abe29c" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="military">
|
||||
<use-line name="fence" />
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- waterways -->
|
||||
<rule e="way" k="waterway" v="*">
|
||||
|
||||
<rule e="way" k="waterway" v="ditch|drain" zoom-min="14">
|
||||
<use-line name="water" width="0.1" fixed="true"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="canal">
|
||||
<use-line name="water" width="-0.2"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="stream" zoom-min="14">
|
||||
<use-line name="water" width="-0.1"/>
|
||||
</rule>
|
||||
|
||||
<style-outline name="river" width="1.0" stroke="#456799" blur="1.0"/>
|
||||
|
||||
<rule e="way" k="waterway" v="river" closed="no">
|
||||
<rule e="way" k="*" v="*" zoom-min="12">
|
||||
<use-line name="water" width="0.5"/>
|
||||
<use-outline name="river"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="*" zoom-max="12">
|
||||
<use-line name="water" width="1.0" fixed="true" fade="9"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule e="way" k="waterway" v="riverbank|dock">
|
||||
<use-area name="water"/>
|
||||
<use-line name="water" width="1.0" fixed="true"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="river" closed="yes">
|
||||
<use-area name="water"/>
|
||||
<use-line name="water" width="1.0" fixed="true"/>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule e="way" k="waterway" v="weir">
|
||||
<line stroke="#000044" width="0.375" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="waterway" v="dam" zoom-min="12">
|
||||
<!-- sehr seltsam was in deutschland so als Damm gekenzeichnet wird.. -->
|
||||
<line stroke="#ababab" width="1.2" cap="butt" fixed="true" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="lock" v="yes|true">
|
||||
<line stroke="#f8f8f8" width="1.5" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="natural" v="water">
|
||||
<use-area name="water"/>
|
||||
<use-line name="water:outline" width="0.5" fixed="true"/>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- sport -->
|
||||
<!-- <rule e="way" k="sport" v="*"> <rule e="way" k="sport" v="soccer"
|
||||
zoom-min="17"> <rule e="way" k="sport" v="swimming|canoe|diving|scuba_diving">
|
||||
<area fill="#b4cbdc" stroke="#6060ff" width="0.2" /> </rule> <rule
|
||||
e="way" k="sport" v="tennis"> <area fill="#d18a6a" stroke="#b36c4c" width="0.2"
|
||||
/> </rule> </rule> -->
|
||||
|
||||
<!-- tourism areas -->
|
||||
<rule e="way" k="tourism" v="*">
|
||||
<!-- <rule e="way" k="tourism" v="attraction"> <area fill="#f2caea" /> </rule> -->
|
||||
|
||||
<rule e="way" k="tourism" v="zoo|picnic_site|caravan_site|camp_site">
|
||||
<area fill="#d7e6b0" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
|
||||
<!-- outline 0 -->
|
||||
|
||||
<style-outline name="0" stroke="#44000000" width="0.1" />
|
||||
<!-- tunnel -->
|
||||
<rule e="way" k="tunnel" v="yes|true" zoom-min="11">
|
||||
<!-- highway tunnels -->
|
||||
<rule e="way" k="highway" v="*">
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<rule e="way" k="*" v="steps">
|
||||
<use-line name="steps"/>
|
||||
<use-outline name="0"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="16">
|
||||
<use-line name="footway:z16"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="15">
|
||||
<use-line name="footway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="bridleway">
|
||||
<use-line name="bridleway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="construction">
|
||||
<use-line name="construction"/>
|
||||
<use-outline name="0"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="service">
|
||||
<rule e="way" k="service" v="-|parking_aisle">
|
||||
<use-line name="highway-service"/>
|
||||
<use-outline name="0"/>
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link">
|
||||
<use-line name="trunk_link"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="13">
|
||||
<rule e="way" k="*" v="byway|pedestrian">
|
||||
<use-line name="pedestrian"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
|
||||
<rule e="way" k="*" v="residential|road|unclassified|living_street">
|
||||
<use-line name="residential"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="tertiary|secondary_link">
|
||||
<use-line name="tertiary"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="secondary|primary_link">
|
||||
<use-line name="secondary:z11"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary">
|
||||
<use-line name="primary:z11"/>
|
||||
<use-outline name="0"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk">
|
||||
<use-line name="trunk" blur="0.3"/>
|
||||
<use-outline name="0"/>
|
||||
<!-- <use-outline name="glow"/> -->
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<use-line name="highway:z11" blur="0.3"/>
|
||||
<use-outline name="0"/>
|
||||
<!-- <use-outline name="glow"/> -->
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- railway tunnel -->
|
||||
<rule e="way" k="railway" v="*">
|
||||
<!-- <rule e="way" k="railway" v="tram|subway|light_rail|narrow_gauge">
|
||||
<line stroke="#a0a0a0" width="0.8" cap="butt" fixed="true"/>
|
||||
</rule> -->
|
||||
<rule e="way" k="railway" v="rail">
|
||||
<line stroke="#aaaaaa" width="0.9" cap="butt" fixed="true" />
|
||||
</rule>
|
||||
</rule>
|
||||
</rule> <!-- end tunnel -->
|
||||
|
||||
|
||||
<!-- platform cores -->
|
||||
<rule e="way" k="highway|railway|public_transport" v="platform">
|
||||
<rule e="way" k="*" v="*" closed="yes">
|
||||
<area fill="#999999" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="*" closed="no">
|
||||
<line stroke="#cccccc" width="0.3" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- runways areas -->
|
||||
<rule e="way" k="aeroway" v="*">
|
||||
<!-- <rule e="way" k="*" v="aerodrome" closed="yes">
|
||||
<area fill="#050008" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="apron">
|
||||
<area fill="#050008" />
|
||||
</rule>-->
|
||||
<!-- Airport passenger building -->
|
||||
<rule e="way" k="*" v="terminal|hangar">
|
||||
<use-area name="building" />
|
||||
<use-line name="building" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- turning circles -->
|
||||
<!-- <rule e="node" k="highway" v="turning_circle"> <circle r="1.5" scale-radius="true"
|
||||
fill="#707070" />
|
||||
</rule> -->
|
||||
|
||||
<!-- building -->
|
||||
<rule e="way" k="building" v="*">
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<use-area name="building" fade="15"/>
|
||||
<use-line name="building" fade="15"/>
|
||||
<!-- <line stroke="#c9c3c1" width="1.0" fixed="true" cap="butt" fade="15"/>
|
||||
<area fill="#e9e6e3" fade="15" /> -->
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="*" zoom-min="17">
|
||||
<caption k="name" font-style="bold" font-size="10" fill="#4040ff"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
<caption k="addr:housenumber" font-style="bold" font-size="10" fill="#606060"
|
||||
stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule> -->
|
||||
</rule>
|
||||
|
||||
<!-- outline 1 - 4 -->
|
||||
<style-outline name="glow3" stroke="#ddffffff" width="0.8" blur="0.5" fade="13"/>
|
||||
<!-- > <style-outline name="glow" stroke="#ee909090" width="0.8" blur="0.5" fade="14"/>-->
|
||||
<style-outline name="glow2" width="1.0" stroke="#ffffff" blur="1.0" fade="13"/>
|
||||
<style-outline name="1" stroke="#dd000000" width="-0.3" fade="14"/>
|
||||
<!-- <style-outline name="1" stroke="#404030"/> -->
|
||||
<style-outline name="2" stroke="#c0c0c0" />
|
||||
<style-outline name="primary" stroke="#7f7700" width="0.025"/>
|
||||
<style-outline name="motorway" stroke="#805f2e" width="0.025"/>
|
||||
|
||||
|
||||
<!-- highway -->
|
||||
<rule e="way" k="highway" v="*">
|
||||
<rule e="way" k="*" v="*" zoom-min="5" zoom-max="10">
|
||||
<rule e="way" k="area" v="~|no|false">
|
||||
<rule e="way" k="*" v="secondary|primary_link" zoom-min="9">
|
||||
<line stroke="#ddf2df6d" width="1.8" cap="butt" fixed="true" fade="9"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link" zoom-min="8">
|
||||
<line stroke="#ddfed6a3" width="1.8" cap="butt" fixed="true" fade="8"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary" zoom-min="5">
|
||||
<line stroke="#ddf2df6d" cap="butt" fixed="true" width="1.8" fade="5"/> <!-- stroke="#f2df6d" width="1.8" cap="butt" fixed="true" fade="5"/>-->
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk" zoom-min="5">
|
||||
<line stroke="#ddfed6a3" width="2.0" cap="butt" fixed="true" fade="5"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<line stroke="#ddeec693" width="2.2" cap="butt" fixed="true" fade="5"/>
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="11">
|
||||
<rule e="way" k="tunnel|bridge" v="~|no|false">
|
||||
<!-- highway area -->
|
||||
<rule e="way" k="area" v="yes|true">
|
||||
|
||||
<rule e="way" k="*" v="footway" zoom-min="15">
|
||||
<area fill="#44ffffff" />
|
||||
<line stroke="#888888" width="0.15" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" zoom-min="13" v="pedestrian|unclassified|residential|road|living_street">
|
||||
<area fill="#44ffffff" />
|
||||
<line stroke="#888888" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="path" zoom-min="14">
|
||||
<area fill="#d0d0d0" />
|
||||
</rule>-->
|
||||
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="area" v="~|no|false">
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<rule e="way" k="*" v="steps">
|
||||
<use-line name="steps"/>
|
||||
<use-outline name="2"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="16" zoom-max="16">
|
||||
<use-line name="footway:z16"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="17">
|
||||
<use-line name="footway:z17"/>
|
||||
<!-- <use-outline name="1"/> -->
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="15">
|
||||
<use-line name="footway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="bridleway">
|
||||
<use-line name="bridleway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="construction">
|
||||
<use-line name="construction"/>
|
||||
<use-outline name="1"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="service">
|
||||
<rule e="way" k="service" v="-|parking_aisle">
|
||||
<use-line name="highway-service"/>
|
||||
<use-outline name="1"/>
|
||||
</rule>
|
||||
<!-- <rule e="way" k="service" v="parking_aisle" zoom-min="16">
|
||||
<use-line name="highway-service" width="-0.4"/>
|
||||
<use-outline name="1"/>
|
||||
</rule> -->
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link">
|
||||
<use-line name="trunk_link"/>
|
||||
<use-outline name="motorway"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="13">
|
||||
<rule e="way" k="*" v="byway|pedestrian">
|
||||
<use-line name="residential" width="-0.4"/>
|
||||
<use-outline name="1"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="residential|road|unclassified|living_street">
|
||||
<use-line name="residential"/>
|
||||
<use-outline name="1"/>
|
||||
|
||||
<use-outline name="glow"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="tertiary|secondary_link">
|
||||
<use-line name="tertiary"/>
|
||||
<use-outline name="1"/>
|
||||
|
||||
<use-outline name="glow"/>
|
||||
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="secondary|primary_link">
|
||||
<!-- <line stroke="#fff939" width="1.6" /> -->
|
||||
<use-line name="secondary:z11"/>
|
||||
<use-outline name="primary"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary">
|
||||
<use-line name="primary:z11"/>
|
||||
<use-outline name="primary"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk">
|
||||
<use-line name="trunk"/>
|
||||
<use-outline name="motorway"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<use-line name="highway:z11"/>
|
||||
<use-outline name="motorway"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
</rule> <!-- end area=~|no|false -->
|
||||
</rule> <!-- end tunnel|bridge=~|no|false -->
|
||||
|
||||
|
||||
<rule e="way" k="bridge" v="yes|true|viaduct|suspension">
|
||||
<rule e="way" k="area" v="~|no|false">
|
||||
|
||||
<style-outline name="bridge" stroke="#aa202020" width="0.08"/>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="15">
|
||||
<rule e="way" k="*" v="steps">
|
||||
<use-line name="steps"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="16" zoom-max="16">
|
||||
<use-line name="footway:z16"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="17">
|
||||
<use-line name="footway:z17" cap="butt"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="15">
|
||||
<use-line name="footway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="bridleway">
|
||||
<use-line name="bridleway"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="construction">
|
||||
<use-line name="construction" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="service">
|
||||
<use-line name="highway-service" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="*" zoom-min="13">
|
||||
<rule e="way" k="*" v="byway|pedestrian">
|
||||
<use-line name="pedestrian:bridge"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="residential|road|unclassified|living_street">
|
||||
<use-line name="residential:bridge"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="tertiary|secondary_link">
|
||||
<use-line name="tertiary" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk_link|motorway_link">
|
||||
<use-line name="trunk_link" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="secondary|primary_link">
|
||||
<!-- <line stroke="#fff939" width="1.6" cap="butt" /> -->
|
||||
<use-line name="secondary:z11" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="primary">
|
||||
<use-line name="primary:z11" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="trunk">
|
||||
<use-line name="trunk" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" v="motorway">
|
||||
<use-line name="highway:z11" cap="square"/>
|
||||
<use-outline name="bridge"/>
|
||||
<use-text name="major-road"/>
|
||||
</rule>
|
||||
</rule> <!-- end area=~|no|false -->
|
||||
|
||||
<rule e="way" k="area" v="yes|true">
|
||||
<rule e="way" k="*" v="footway" zoom-min="15">
|
||||
<area fill="#fefefe" />
|
||||
<line stroke="#c0c0c0" width="0.15" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="*" zoom-min="13" v="pedestrian|service|unclassified|residential|road|living_street">
|
||||
<area fill="#ffffff" />
|
||||
<line stroke="#d0d0d0" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
<!-- <rule e="way" k="*" v="path" zoom-min="14">
|
||||
<area fill="#d0d0d0" />
|
||||
</rule>-->
|
||||
</rule> <!-- end area=yes|true -->
|
||||
</rule> <!-- end bridge=yes -->
|
||||
</rule> <!-- end zoom-min=11 -->
|
||||
</rule> <!-- end highway -->
|
||||
|
||||
|
||||
<!-- runways cores -->
|
||||
<rule e="way" k="aeroway" v="*">
|
||||
<rule e="way" k="*" v="runway">
|
||||
<use-line name="aeroway:runway"/>
|
||||
</rule>
|
||||
<rule e="way" k="*" v="taxiway">
|
||||
<use-line name="aeroway:runway" width="-0.8"/>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- man_made features -->
|
||||
<!-- <rule e="way" k="man_made" v="pier">
|
||||
<rule e="way" k="*" v="*" closed="no">
|
||||
<line stroke="#d0d0d0" width="0.4" cap="butt" />
|
||||
<line stroke="#e4e4e4" width="0.3" cap="butt" />
|
||||
</rule>
|
||||
<rule e="way" k="*" v="*" closed="yes">
|
||||
<area fill="#e4e4e4" stroke="#d0d0d0" stroke-width="0.05" />
|
||||
</rule>
|
||||
</rule> -->
|
||||
|
||||
|
||||
<!-- barriers -->
|
||||
<rule e="way" k="barrier" v="*">
|
||||
<!-- <rule e="way" k="*" v="fence|wall|city_wall" zoom-min="15"> <line
|
||||
stroke="#909090" width="0.1" cap="butt" /> </rule> -->
|
||||
<rule e="way" k="*" v="retaining_wall" zoom-min="15">
|
||||
<line stroke="#888888" width="0.1" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- non-physical routes -->
|
||||
<!-- <rule e="way" k="route" v="ferry"> <line stroke="#707070" width="0.3"
|
||||
stroke-dasharray="15,10" cap="butt" /> </rule> -->
|
||||
|
||||
<!-- aerial ways -->
|
||||
<!-- <rule e="way" k="aerialway" v="*"> <line stroke="#202020" width="0.4"
|
||||
cap="butt" /> <rule e="way" k="aerialway" v="cable_car"> <lineSymbol
|
||||
src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/cable_car.png"
|
||||
/> </rule> <rule e="way" k="aerialway" v="chair_lift"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/chair_lift_2.png"
|
||||
/> </rule> <rule e="way" k="aerialway" v="gondola"> <lineSymbol src="jar:/org/mapsforge/android/maps/rendertheme/osmarender/symbols/gondola.png"
|
||||
/> </rule> <rule e="way" k="*" v="*" zoom-min="14"> <pathText k="name" font-style="bold"
|
||||
font-size="10" fill="#606060" stroke="#ffffff" width="2.0" /> </rule>
|
||||
</rule> -->
|
||||
|
||||
|
||||
<!-- railway (no tunnel) -->
|
||||
<rule e="way" k="railway" v="*" zoom-min="12">
|
||||
<rule e="way" k="tunnel" v="~|false|no">
|
||||
|
||||
<rule e="way" k="railway" v="station">
|
||||
<area fill="#aa000000" />
|
||||
<line stroke="#cccccc" width="1.0" fixed="true"/>
|
||||
</rule>
|
||||
|
||||
<!-- railway bridge casings -->
|
||||
<rule e="way" k="*" v="*" zoom-min="14">
|
||||
<rule e="way" k="bridge" v="yes|true">
|
||||
<rule e="way" k="railway" v="tram">
|
||||
<line stroke="#777777" width="0.9" cap="butt"
|
||||
fixed="true" />
|
||||
</rule>
|
||||
<rule e="way" k="railway" v="subway|light_rail|narrow_gauge">
|
||||
<line stroke="#777777" width="0.9" cap="butt"
|
||||
fixed="true" />
|
||||
</rule>
|
||||
<rule e="way" k="railway" v="rail">
|
||||
<line stroke="#777777" width="0.9" cap="butt"
|
||||
fixed="true" />
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<!-- railway casings and cores -->
|
||||
<rule e="way" k="railway" v="tram" zoom-min="15">
|
||||
<line stroke="#887766" width="1.0" fixed="true" />
|
||||
</rule>
|
||||
|
||||
<rule e="way" k="railway" v="light_rail|subway|narrow_gauge" zoom-min="14">
|
||||
<line stroke="#a0a0a0" width="0.9" cap="butt" fixed="true" />
|
||||
|
||||
</rule>
|
||||
<rule e="way" k="railway" v="rail|turntable" >
|
||||
<line stroke="#aaaaaa" width="1.0" cap="butt" fixed="true" fade="12"/>
|
||||
</rule>
|
||||
<!-- <rule e="way" k="railway" v="rail" zoom-max="14" zoom-min="13">
|
||||
<line stroke="#8888aa" width="0.6" cap="butt"
|
||||
fixed="true" />
|
||||
</rule> -->
|
||||
<!-- <rule e="way" k="railway" v="rail" zoom-max="13" zoom-min="11">
|
||||
<line stroke="#bbbbcc" width="0.8" cap="butt" fixed="true" />
|
||||
</rule> -->
|
||||
<!-- whatever railway:spur means ... -->
|
||||
<rule e="way" k="railway" v="disused|spur|abandoned|preserved" >
|
||||
<line stroke="#cccccc" width="0.8" cap="butt" fixed="true" fade="12"/>
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- non-physical boundaries -->
|
||||
<!-- <rule e="way" k="boundary" v="*"> <rule e="way" k="boundary" v="national_park">
|
||||
<line stroke="#4ef94b" width="0.25" stroke-dasharray="15, 5, 5, 5"
|
||||
/> -->
|
||||
|
||||
<!--<rule e="way" k="boundary" v="administrative"> -->
|
||||
<rule e="way" k="admin_level" v="*">
|
||||
<!-- <rule e="way" k="admin_level" v="11"> <line stroke="#f9574b" width="0.1"
|
||||
fixed="true" cap="butt" /> </rule> <rule e="way" k="admin_level"
|
||||
v="10"> <line stroke="#f9574b" width="0.1" fixed="true" cap="butt"
|
||||
/> </rule> <rule e="way" k="admin_level" v="9"> <line stroke="#f9574b" width="0.1"
|
||||
fixed="true" cap="butt" /> </rule> <rule e="way" k="admin_level"
|
||||
v="8"> <line stroke="#f9574b" width="0.3" fixed="true" cap="butt"
|
||||
/> </rule> <rule e="way" k="admin_level" v="7"> <line stroke="#f9574b" width="0.1"
|
||||
fixed="true" cap="butt" /> </rule> <rule e="way" k="admin_level"
|
||||
v="6"> <line stroke="#f9574b" width="0.15" fixed="true" cap="butt"
|
||||
/> </rule> <rule e="way" k="admin_level" v="5"> <line stroke="#f9574b" width="0.15"
|
||||
fixed="true" cap="butt" /> </rule> -->
|
||||
<rule e="way" k="admin_level" v="4">
|
||||
<line stroke="#8f80dd" width="0.9" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
<rule e="way" k="admin_level" v="3">
|
||||
<line stroke="#0000ff" width="1.0" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
<rule e="way" k="admin_level" v="2">
|
||||
<line stroke="#dddddd" width="1.0" fixed="true" cap="butt" blur="0.3"/>
|
||||
</rule>
|
||||
<rule e="way" k="admin_level" v="1">
|
||||
<line stroke="#ff0000" width="0.95" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
|
||||
</rule>
|
||||
<!-- </rule> -->
|
||||
|
||||
|
||||
<!-- historic -->
|
||||
<!-- <rule e="way" k="historic" v="ruins" zoom-min="17">
|
||||
<caption k="name" font-style="bold" font-size="10" fill="#4040ff" stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule> -->
|
||||
|
||||
<!-- place -->
|
||||
<rule e="way" k="place" v="locality" zoom-min="17">
|
||||
<caption k="name" font-style="bold" font-size="10" fill="#000000" stroke="#ffffff" stroke-width="2.0" />
|
||||
</rule>
|
||||
<rule e="way" k="debug" v="area">
|
||||
<line stroke="#ff0000" width="1.2" fixed="true" cap="butt" />
|
||||
<area fill="#880000ff"/>
|
||||
<caption k="name" font-size="15" fill="#ff0000" stroke="#444444" stroke-width="2.0"/>
|
||||
</rule>
|
||||
<rule e="way" k="debug" v="way">
|
||||
<line stroke="#00ffff" width="1.5" fixed="true" cap="butt" />
|
||||
<caption k="name" font-size="15" fill="#00ffff" stroke="#444444" stroke-width="2.0"/>
|
||||
</rule>
|
||||
<rule e="way" k="debug" v="box">
|
||||
<line stroke="#dedeae" width="1.5" fixed="true" cap="butt" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
<rule e="node" k="*" v="*">
|
||||
<!-- barrier -->
|
||||
<rule e="node" k="barrier" v="bollard">
|
||||
<circle r="1.5" fill="#909090" />
|
||||
</rule>
|
||||
|
||||
<rule e="node" k="debug" v="*" >
|
||||
<caption k="name" font-size="16" fill="#fefece"/>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- highway -->
|
||||
<!-- <rule e="node" k="highway" v="*"> <rule e="node" k="highway" v="turning_circle">
|
||||
<circle r="1.4" scale-radius="true" fill="#ffffff" /> </rule> </rule> -->
|
||||
|
||||
<!-- historic -->
|
||||
<!-- <rule e="node" k="historic" v="*"> <circle r="3" fill="#4040ff" stroke="#606060"
|
||||
width="1.5" /> <rule e="node" k="*" v="*" zoom-min="17"> <caption
|
||||
k="name" dy="-10" font-style="bold" font-size="10" fill="#4040ff" stroke="#ffffff"
|
||||
width="2.0" /> </rule> </rule> -->
|
||||
|
||||
|
||||
<!-- house numbers -->
|
||||
<!-- <rule e="node" k="addr:housenumber" v="*" zoom-min="18"> <caption
|
||||
k="addr:housenumber" font-style="bold" font-size="10" fill="#606060" stroke="#ffffff"
|
||||
width="2.0" /> </rule> -->
|
||||
|
||||
|
||||
|
||||
<!-- place -->
|
||||
<rule e="node" k="place" v="*">
|
||||
<rule e="node" k="*" v="suburb|town|village">
|
||||
<caption k="name" font-size="20" fill="#eeeeee"
|
||||
stroke="#000020" stroke-width="4.0" />
|
||||
</rule>
|
||||
<rule e="node" k="*" v="island" zoom-min="10">
|
||||
<caption k="name" font-style="bold" font-size="20" fill="#ffffff"
|
||||
stroke="#ffffff" stroke-width="1.0" />
|
||||
</rule>
|
||||
<rule e="node" k="*" v="city">
|
||||
<caption k="name" font-style="bold" font-size="22" fill="#ffffff"
|
||||
stroke="#002020" stroke-width="4.0" />
|
||||
</rule>
|
||||
<rule e="node" k="*" v="country">
|
||||
<caption k="name" font-size="22" fill="#ffffff"
|
||||
stroke="#000000" stroke-width="2.0" />
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
|
||||
<!-- railway -->
|
||||
<rule e="node" k="railway" v="*">
|
||||
<rule e="node" k="*" v="station" zoom-min="14">
|
||||
<circle r="6" fill="#ec2d2d" stroke="#606060" width="1.5" />
|
||||
<!-- <caption k="name" dy="-10" font-style="bold" font-size="13" fill="#ec2d2d"
|
||||
stroke="#ffffff" stroke-width="2.0" /> -->
|
||||
</rule>
|
||||
<rule e="node" k="*" v="halt|tram_stop" zoom-min="17">
|
||||
<circle r="4" fill="#ec2d2d" stroke="#606060" width="1.5" />
|
||||
<!-- <caption k="name" dy="-15" font-style="bold" font-size="11" fill="#ec2d2d"
|
||||
stroke="#ffffff" stroke-width="2.0" /> -->
|
||||
</rule>
|
||||
</rule>
|
||||
</rule>
|
||||
|
||||
</rendertheme>
|
||||
241
src/org/oscim/theme/renderTheme.xsd
Normal file
241
src/org/oscim/theme/renderTheme.xsd
Normal file
@@ -0,0 +1,241 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://mapsforge.org/renderTheme" xmlns:tns="http://mapsforge.org/renderTheme"
|
||||
elementFormDefault="qualified" xml:lang="en">
|
||||
<!-- attribute types -->
|
||||
<xs:simpleType name="cap">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="butt" />
|
||||
<xs:enumeration value="round" />
|
||||
<xs:enumeration value="square" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="closed">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="yes" />
|
||||
<xs:enumeration value="no" />
|
||||
<xs:enumeration value="any" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="color">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="elementList">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="node" />
|
||||
<xs:enumeration value="way" />
|
||||
<xs:enumeration value="any" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="fontFamily">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="default" />
|
||||
<xs:enumeration value="default_bold" />
|
||||
<xs:enumeration value="monospace" />
|
||||
<xs:enumeration value="sans_serif" />
|
||||
<xs:enumeration value="serif" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="fontStyle">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="bold" />
|
||||
<xs:enumeration value="bold_italic" />
|
||||
<xs:enumeration value="italic" />
|
||||
<xs:enumeration value="normal" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="nonNegativeFloat">
|
||||
<xs:restriction base="xs:float">
|
||||
<xs:minInclusive value="0" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="src">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(jar|file)\:.+" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="strokeDasharray">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern
|
||||
value="([0-9]+(\.[0-9]+)? *, *[0-9]+(\.[0-9]+)? *, *)*[0-9]+(\.[0-9]+)? *, *[0-9]+(\.[0-9]+)?" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<xs:simpleType name="textKey">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="ele" />
|
||||
<xs:enumeration value="addr:housenumber" />
|
||||
<xs:enumeration value="name" />
|
||||
<xs:enumeration value="ref" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
|
||||
<!-- rendering instructions -->
|
||||
<xs:complexType name="area">
|
||||
<xs:attribute name="src" type="tns:src" use="optional" />
|
||||
<xs:attribute name="fill" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
<xs:attribute name="stroke" type="tns:color" u se="optional"
|
||||
default="#00000000" />
|
||||
<xs:attribute name="stroke-width" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
<xs:attribute name="fade" type="xs:integer" use="optional"
|
||||
default="-1" />
|
||||
<xs:attribute name="blend" type="xs:integer" use="optional"
|
||||
default="-1" />
|
||||
<xs:attribute name="blend-fill" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="caption">
|
||||
<xs:attribute name="k" type="tns:textKey" use="required" />
|
||||
<xs:attribute name="dy" type="xs:float" use="optional"
|
||||
default="0" />
|
||||
<xs:attribute name="font-family" type="tns:fontFamily"
|
||||
use="optional" default="default" />
|
||||
<xs:attribute name="font-style" type="tns:fontStyle" use="optional"
|
||||
default="normal" />
|
||||
<xs:attribute name="font-size" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
<xs:attribute name="fill" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
<xs:attribute name="stroke" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
<xs:attribute name="stroke-width" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="circle">
|
||||
<xs:attribute name="r" type="tns:nonNegativeFloat" use="required" />
|
||||
<xs:attribute name="scale-radius" type="xs:boolean" use="optional"
|
||||
default="false" />
|
||||
<xs:attribute name="fill" type="tns:color" use="optional"
|
||||
default="#00000000" />
|
||||
<xs:attribute name="stroke" type="tns:color" use="optional"
|
||||
default="#00000000" />
|
||||
<xs:attribute name="stroke-width" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="line">
|
||||
<xs:attribute name="src" type="tns:src" use="optional" />
|
||||
<xs:attribute name="stroke" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
<xs:attribute name="width" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
<xs:attribute name="stroke-dasharray" type="tns:strokeDasharray"
|
||||
use="optional" />
|
||||
<xs:attribute name="cap" type="tns:cap" use="optional"
|
||||
default="round" />
|
||||
<xs:attribute name="outline" type="xs:integer" use="optional"
|
||||
default="0" />
|
||||
<xs:attribute name="fade" type="xs:integer" use="optional"
|
||||
default="-1" />
|
||||
<xs:attribute name="fixed" type="xs:boolean" use="optional"
|
||||
default="false" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="outline">
|
||||
<xs:attribute name="src" type="tns:src" use="optional" />
|
||||
<xs:attribute name="stroke" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
<xs:attribute name="stroke-width" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="lineSymbol">
|
||||
<xs:attribute name="src" type="tns:src" use="required" />
|
||||
<xs:attribute name="align-center" type="xs:boolean" use="optional"
|
||||
default="false" />
|
||||
<xs:attribute name="repeat" type="xs:boolean" use="optional"
|
||||
default="false" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="pathText">
|
||||
<xs:attribute name="style" type="xs:string" use="optional" default="0"/>
|
||||
<xs:attribute name="k" type="tns:textKey" use="required" />
|
||||
<xs:attribute name="dy" type="xs:float" use="optional"
|
||||
default="0" />
|
||||
<xs:attribute name="font-family" type="tns:fontFamily"
|
||||
use="optional" default="default" />
|
||||
<xs:attribute name="font-style" type="tns:fontStyle" use="optional"
|
||||
default="normal" />
|
||||
<xs:attribute name="font-size" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
<xs:attribute name="fill" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
<xs:attribute name="stroke" type="tns:color" use="optional"
|
||||
default="#000000" />
|
||||
<xs:attribute name="stroke-width" type="tns:nonNegativeFloat"
|
||||
use="optional" default="0" />
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="symbol">
|
||||
<xs:attribute name="src" type="tns:src" use="required" />
|
||||
</xs:complexType>
|
||||
|
||||
|
||||
<!-- rule elements -->
|
||||
<xs:complexType name="rule">
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<!-- recursion to allow for nested rules -->
|
||||
<xs:element name="rule" type="tns:rule" />
|
||||
|
||||
<xs:element name="area" type="tns:area" />
|
||||
<xs:element name="caption" type="tns:caption" />
|
||||
<xs:element name="circle" type="tns:circle" />
|
||||
<xs:element name="line" type="tns:line" />
|
||||
<xs:element name="outline" type="tns:outline" />
|
||||
<xs:element name="lineSymbol" type="tns:lineSymbol" />
|
||||
<xs:element name="pathText" type="tns:pathText" />
|
||||
<xs:element name="stylePathText type="xs:string" />
|
||||
<xs:element name="symbol" type="tns:symbol" />
|
||||
</xs:choice>
|
||||
<xs:attribute name="e" type="tns:elementList" use="required" />
|
||||
<xs:attribute name="k" type="xs:string" use="required" />
|
||||
<xs:attribute name="v" type="xs:string" use="required" />
|
||||
<xs:attribute name="closed" type="tns:closed" use="optional"
|
||||
default="any" />
|
||||
<xs:attribute name="zoom-min" type="xs:unsignedByte" use="optional"
|
||||
default="0" />
|
||||
<xs:attribute name="zoom-max" type="xs:unsignedByte" use="optional"
|
||||
default="127" />
|
||||
</xs:complexType>
|
||||
|
||||
|
||||
<!-- rendertheme element -->
|
||||
<xs:complexType name="rendertheme">
|
||||
<xs:sequence minOccurs="0" maxOccurds="256">
|
||||
<xs:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="style-pathtext" type="tns:pathText" />
|
||||
<xs:element name="style-area" type="tns:area" />
|
||||
</xs:choice>
|
||||
</xs:sequence)
|
||||
<xs:sequence minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:element name="rule" type="tns:rule" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="version" type="xs:positiveInteger"
|
||||
use="required" />
|
||||
<xs:attribute name="map-background" type="tns:color" use="optional"
|
||||
default="#ffffff" />
|
||||
<xs:attribute name="base-stroke-width" type="tns:nonNegativeFloat"
|
||||
use="optional" default="1" />
|
||||
<xs:attribute name="base-text-size" type="tns:nonNegativeFloat"
|
||||
use="optional" default="1" />
|
||||
</xs:complexType>
|
||||
|
||||
|
||||
<!-- root element -->
|
||||
<xs:element name="rendertheme" type="tns:rendertheme" />
|
||||
</xs:schema>
|
||||
179
src/org/oscim/theme/renderinstruction/Area.java
Normal file
179
src/org/oscim/theme/renderinstruction/Area.java
Normal file
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
import org.oscim.theme.RenderThemeHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
/**
|
||||
* Represents a closed polygon on the map.
|
||||
*/
|
||||
public final class Area extends RenderInstruction {
|
||||
/**
|
||||
* @param elementName
|
||||
* the name of the XML element.
|
||||
* @param attributes
|
||||
* the attributes of the XML element.
|
||||
* @param level
|
||||
* the drawing level of this instruction.
|
||||
* @return a new Area with the given rendering attributes.
|
||||
*/
|
||||
public static Area create(String elementName, Attributes attributes, int level) {
|
||||
String src = null;
|
||||
int fill = Color.BLACK;
|
||||
int stroke = Color.TRANSPARENT;
|
||||
float strokeWidth = 0;
|
||||
int fade = -1;
|
||||
int blend = -1;
|
||||
int blendFill = Color.BLACK;
|
||||
String style = null;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
if ("name".equals(name))
|
||||
style = value;
|
||||
else if ("src".equals(name)) {
|
||||
src = value;
|
||||
} else if ("fill".equals(name)) {
|
||||
fill = Color.parseColor(value);
|
||||
} else if ("stroke".equals(name)) {
|
||||
stroke = Color.parseColor(value);
|
||||
} else if ("stroke-width".equals(name)) {
|
||||
strokeWidth = Float.parseFloat(value);
|
||||
} else if ("fade".equals(name)) {
|
||||
fade = Integer.parseInt(value);
|
||||
} else if ("blend".equals(name)) {
|
||||
blend = Integer.parseInt(value);
|
||||
} else if ("blend-fill".equals(name)) {
|
||||
blendFill = Color.parseColor(value);
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(strokeWidth);
|
||||
return new Area(style, src, fill, stroke, strokeWidth, fade, level, blend,
|
||||
blendFill);
|
||||
}
|
||||
|
||||
private static void validate(float strokeWidth) {
|
||||
if (strokeWidth < 0) {
|
||||
throw new IllegalArgumentException("stroke-width must not be negative: "
|
||||
+ strokeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
private Area(String style, String src, int fill, int stroke, float strokeWidth,
|
||||
int fade, int level, int blend, int blendFill) {
|
||||
super();
|
||||
this.style = style;
|
||||
|
||||
// if (fill == Color.TRANSPARENT) {
|
||||
// paintFill = null;
|
||||
// } else {
|
||||
// paintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
// if (src != null) {
|
||||
// Shader shader = BitmapUtils.createBitmapShader(src);
|
||||
// paintFill.setShader(shader);
|
||||
// }
|
||||
// paintFill.setStyle(Style.FILL);
|
||||
// paintFill.setColor(fill);
|
||||
// paintFill.setStrokeCap(Cap.ROUND);
|
||||
// }
|
||||
//
|
||||
// if (stroke == Color.TRANSPARENT) {
|
||||
// paintOutline = null;
|
||||
// } else {
|
||||
// paintOutline = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
// paintOutline.setStyle(Style.STROKE);
|
||||
// paintOutline.setColor(stroke);
|
||||
// paintOutline.setStrokeCap(Cap.ROUND);
|
||||
// }
|
||||
|
||||
// if (stroke == Color.TRANSPARENT) {
|
||||
// stroke = null;
|
||||
// } else{
|
||||
// stroke = new Line()
|
||||
// }
|
||||
|
||||
color = new float[4];
|
||||
color[3] = (fill >> 24 & 0xff) / 255.0f;
|
||||
color[0] = (fill >> 16 & 0xff) / 255.0f * color[3];
|
||||
color[1] = (fill >> 8 & 0xff) / 255.0f * color[3];
|
||||
color[2] = (fill >> 0 & 0xff) / 255.0f * color[3];
|
||||
|
||||
if (blend > 0) {
|
||||
blendColor = new float[4];
|
||||
blendColor[3] = (blendFill >> 24 & 0xff) / 255.0f;
|
||||
blendColor[0] = (blendFill >> 16 & 0xff) / 255.0f * blendColor[3];
|
||||
blendColor[1] = (blendFill >> 8 & 0xff) / 255.0f * blendColor[3];
|
||||
blendColor[2] = (blendFill >> 0 & 0xff) / 255.0f * blendColor[3];
|
||||
} else {
|
||||
blendColor = null;
|
||||
}
|
||||
|
||||
this.blend = blend;
|
||||
this.strokeWidth = strokeWidth;
|
||||
this.fade = fade;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderArea(this, this.level);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void scaleStrokeWidth(float scaleFactor) {
|
||||
// // if (paintOutline != null) {
|
||||
// // paintOutline.setStrokeWidth(strokeWidth * scaleFactor);
|
||||
// // }
|
||||
// }
|
||||
|
||||
public String style;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final int level;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// public final Paint paintFill;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// public final Paint paintOutline;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final float strokeWidth;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final float color[];
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final int fade;
|
||||
|
||||
public final float blendColor[];
|
||||
|
||||
public final int blend;
|
||||
}
|
||||
33
src/org/oscim/theme/renderinstruction/AreaLevel.java
Normal file
33
src/org/oscim/theme/renderinstruction/AreaLevel.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
|
||||
public class AreaLevel extends RenderInstruction {
|
||||
private final Area area;
|
||||
private final int level;
|
||||
|
||||
public AreaLevel(Area area, int level) {
|
||||
this.area = area;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderArea(this.area, level);
|
||||
}
|
||||
}
|
||||
78
src/org/oscim/theme/renderinstruction/BitmapUtils.java
Normal file
78
src/org/oscim/theme/renderinstruction/BitmapUtils.java
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Shader.TileMode;
|
||||
|
||||
final class BitmapUtils {
|
||||
private static final String PREFIX_FILE = "file:";
|
||||
private static final String PREFIX_JAR = "jar:";
|
||||
|
||||
private static InputStream createInputStream(String src) throws FileNotFoundException {
|
||||
if (src.startsWith(PREFIX_JAR)) {
|
||||
String name = src.substring(PREFIX_JAR.length());
|
||||
InputStream inputStream = Thread.currentThread().getClass().getResourceAsStream(name);
|
||||
if (inputStream == null) {
|
||||
throw new FileNotFoundException("resource not found: " + src);
|
||||
}
|
||||
return inputStream;
|
||||
} else if (src.startsWith(PREFIX_FILE)) {
|
||||
File file = new File(src.substring(PREFIX_FILE.length()));
|
||||
if (!file.exists()) {
|
||||
throw new IllegalArgumentException("file does not exist: " + src);
|
||||
} else if (!file.isFile()) {
|
||||
throw new IllegalArgumentException("not a file: " + src);
|
||||
} else if (!file.canRead()) {
|
||||
throw new IllegalArgumentException("cannot read file: " + src);
|
||||
}
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
throw new IllegalArgumentException("invalid bitmap source: " + src);
|
||||
}
|
||||
|
||||
static Bitmap createBitmap(String src) throws IOException {
|
||||
if (src == null || src.length() == 0) {
|
||||
// no image source defined
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream inputStream = createInputStream(src);
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
inputStream.close();
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
static BitmapShader createBitmapShader(String src) throws IOException {
|
||||
Bitmap bitmap = BitmapUtils.createBitmap(src);
|
||||
if (bitmap == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT);
|
||||
}
|
||||
|
||||
private BitmapUtils() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
148
src/org/oscim/theme/renderinstruction/Caption.java
Normal file
148
src/org/oscim/theme/renderinstruction/Caption.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
import org.oscim.theme.RenderThemeHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.FontMetrics;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.FloatMath;
|
||||
|
||||
/**
|
||||
* Represents a text label on the map.
|
||||
*/
|
||||
public final class Caption extends RenderInstruction {
|
||||
/**
|
||||
* @param elementName
|
||||
* the name of the XML element.
|
||||
* @param attributes
|
||||
* the attributes of the XML element.
|
||||
* @return a new Caption with the given rendering attributes.
|
||||
*/
|
||||
public static Caption create(String elementName, Attributes attributes) {
|
||||
String textKey = null;
|
||||
float dy = 0;
|
||||
FontFamily fontFamily = FontFamily.DEFAULT;
|
||||
FontStyle fontStyle = FontStyle.NORMAL;
|
||||
float fontSize = 0;
|
||||
int fill = Color.BLACK;
|
||||
int stroke = Color.BLACK;
|
||||
float strokeWidth = 0;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
|
||||
if ("k".equals(name)) {
|
||||
textKey = TextKey.getInstance(value);
|
||||
} else if ("dy".equals(name)) {
|
||||
dy = Float.parseFloat(value);
|
||||
} else if ("font-family".equals(name)) {
|
||||
fontFamily = FontFamily.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
} else if ("font-style".equals(name)) {
|
||||
fontStyle = FontStyle.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
} else if ("font-size".equals(name)) {
|
||||
fontSize = Float.parseFloat(value);
|
||||
} else if ("fill".equals(name)) {
|
||||
fill = Color.parseColor(value);
|
||||
} else if ("stroke".equals(name)) {
|
||||
stroke = Color.parseColor(value);
|
||||
} else if ("stroke-width".equals(name)) {
|
||||
strokeWidth = Float.parseFloat(value);
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(elementName, textKey, fontSize, strokeWidth);
|
||||
Typeface typeface = Typeface.create(fontFamily.toTypeface(), fontStyle.toInt());
|
||||
return new Caption(textKey, dy, typeface, fontSize, fill, stroke, strokeWidth);
|
||||
}
|
||||
|
||||
private static void validate(String elementName, String textKey, float fontSize,
|
||||
float strokeWidth) {
|
||||
if (textKey == null) {
|
||||
throw new IllegalArgumentException("missing attribute k for element: "
|
||||
+ elementName);
|
||||
} else if (fontSize < 0) {
|
||||
throw new IllegalArgumentException("font-size must not be negative: "
|
||||
+ fontSize);
|
||||
} else if (strokeWidth < 0) {
|
||||
throw new IllegalArgumentException("stroke-width must not be negative: "
|
||||
+ strokeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
public final float dy;
|
||||
public float fontSize;
|
||||
public final Paint paint;
|
||||
public final Paint stroke;
|
||||
public final String textKey;
|
||||
public final float fontHeight;
|
||||
public final float fontDescent;
|
||||
|
||||
private Caption(String textKey, float dy, Typeface typeface, float fontSize,
|
||||
int fillColor, int strokeColor, float strokeWidth) {
|
||||
super();
|
||||
|
||||
this.textKey = textKey.intern();
|
||||
this.dy = dy;
|
||||
this.fontSize = fontSize;
|
||||
|
||||
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
paint.setTypeface(typeface);
|
||||
paint.setColor(fillColor);
|
||||
|
||||
stroke = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
stroke.setStyle(Style.STROKE);
|
||||
stroke.setTextAlign(Align.CENTER);
|
||||
stroke.setTypeface(typeface);
|
||||
stroke.setColor(strokeColor);
|
||||
stroke.setStrokeWidth(strokeWidth);
|
||||
|
||||
paint.setTextSize(fontSize);
|
||||
stroke.setTextSize(fontSize);
|
||||
|
||||
FontMetrics fm = paint.getFontMetrics();
|
||||
fontHeight = FloatMath.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
|
||||
fontDescent = FloatMath.ceil(Math.abs(fm.descent));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderPointOfInterestCaption(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderAreaCaption(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scaleTextSize(float scaleFactor) {
|
||||
paint.setTextSize(fontSize * scaleFactor);
|
||||
stroke.setTextSize(fontSize * scaleFactor);
|
||||
}
|
||||
}
|
||||
142
src/org/oscim/theme/renderinstruction/Circle.java
Normal file
142
src/org/oscim/theme/renderinstruction/Circle.java
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
import org.oscim.theme.RenderThemeHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
|
||||
/**
|
||||
* Represents a round area on the map.
|
||||
*/
|
||||
public final class Circle extends RenderInstruction {
|
||||
/**
|
||||
* @param elementName
|
||||
* the name of the XML element.
|
||||
* @param attributes
|
||||
* the attributes of the XML element.
|
||||
* @param level
|
||||
* the drawing level of this instruction.
|
||||
* @return a new Circle with the given rendering attributes.
|
||||
*/
|
||||
public static Circle create(String elementName, Attributes attributes, int level) {
|
||||
Float radius = null;
|
||||
boolean scaleRadius = false;
|
||||
int fill = Color.TRANSPARENT;
|
||||
int stroke = Color.TRANSPARENT;
|
||||
float strokeWidth = 0;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
|
||||
if ("r".equals(name)) {
|
||||
radius = Float.valueOf(Float.parseFloat(value));
|
||||
} else if ("scale-radius".equals(name)) {
|
||||
scaleRadius = Boolean.parseBoolean(value);
|
||||
} else if ("fill".equals(name)) {
|
||||
fill = Color.parseColor(value);
|
||||
} else if ("stroke".equals(name)) {
|
||||
stroke = Color.parseColor(value);
|
||||
} else if ("stroke-width".equals(name)) {
|
||||
strokeWidth = Float.parseFloat(value);
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(elementName, radius, strokeWidth);
|
||||
return new Circle(radius, scaleRadius, fill, stroke, strokeWidth, level);
|
||||
}
|
||||
|
||||
private static void validate(String elementName, Float radius, float strokeWidth) {
|
||||
if (radius == null) {
|
||||
throw new IllegalArgumentException("missing attribute r for element: "
|
||||
+ elementName);
|
||||
} else if (radius.floatValue() < 0) {
|
||||
throw new IllegalArgumentException("radius must not be negative: " + radius);
|
||||
} else if (strokeWidth < 0) {
|
||||
throw new IllegalArgumentException("stroke-width must not be negative: "
|
||||
+ strokeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
private final Paint mFill;
|
||||
private final int mLevel;
|
||||
private final Paint mOutline;
|
||||
private final float mRadius;
|
||||
private float mRenderRadius;
|
||||
private final boolean mScaleRadius;
|
||||
private final float mStrokeWidth;
|
||||
|
||||
private Circle(Float radius, boolean scaleRadius, int fill, int stroke,
|
||||
float strokeWidth, int level) {
|
||||
super();
|
||||
|
||||
mRadius = radius.floatValue();
|
||||
mScaleRadius = scaleRadius;
|
||||
|
||||
if (fill == Color.TRANSPARENT) {
|
||||
mFill = null;
|
||||
} else {
|
||||
mFill = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mFill.setStyle(Style.FILL);
|
||||
mFill.setColor(fill);
|
||||
}
|
||||
|
||||
if (stroke == Color.TRANSPARENT) {
|
||||
mOutline = null;
|
||||
} else {
|
||||
mOutline = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mOutline.setStyle(Style.STROKE);
|
||||
mOutline.setColor(stroke);
|
||||
}
|
||||
|
||||
mStrokeWidth = strokeWidth;
|
||||
mLevel = level;
|
||||
|
||||
if (!mScaleRadius) {
|
||||
mRenderRadius = mRadius;
|
||||
if (mOutline != null) {
|
||||
mOutline.setStrokeWidth(mStrokeWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
|
||||
if (mOutline != null) {
|
||||
renderCallback.renderPointOfInterestCircle(mRenderRadius, mOutline, mLevel);
|
||||
}
|
||||
if (mFill != null) {
|
||||
renderCallback.renderPointOfInterestCircle(mRenderRadius, mFill, mLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scaleStrokeWidth(float scaleFactor) {
|
||||
if (mScaleRadius) {
|
||||
mRenderRadius = mRadius * scaleFactor;
|
||||
if (mOutline != null) {
|
||||
mOutline.setStrokeWidth(mStrokeWidth * scaleFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
src/org/oscim/theme/renderinstruction/FontFamily.java
Normal file
42
src/org/oscim/theme/renderinstruction/FontFamily.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
|
||||
enum FontFamily {
|
||||
DEFAULT, DEFAULT_BOLD, MONOSPACE, SANS_SERIF, SERIF;
|
||||
|
||||
/**
|
||||
* @return the typeface object of this FontFamily.
|
||||
* @see <a href="http://developer.android.com/reference/android/graphics/Typeface.html">Typeface</a>
|
||||
*/
|
||||
Typeface toTypeface() {
|
||||
switch (this) {
|
||||
case DEFAULT:
|
||||
return Typeface.DEFAULT;
|
||||
case DEFAULT_BOLD:
|
||||
return Typeface.DEFAULT_BOLD;
|
||||
case MONOSPACE:
|
||||
return Typeface.MONOSPACE;
|
||||
case SANS_SERIF:
|
||||
return Typeface.SANS_SERIF;
|
||||
case SERIF:
|
||||
return Typeface.SERIF;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown enum value: " + this);
|
||||
}
|
||||
}
|
||||
38
src/org/oscim/theme/renderinstruction/FontStyle.java
Normal file
38
src/org/oscim/theme/renderinstruction/FontStyle.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
enum FontStyle {
|
||||
BOLD, BOLD_ITALIC, ITALIC, NORMAL;
|
||||
|
||||
/**
|
||||
* @return the constant int value of this FontStyle.
|
||||
* @see <a href="http://developer.android.com/reference/android/graphics/Typeface.html">Typeface</a>
|
||||
*/
|
||||
int toInt() {
|
||||
switch (this) {
|
||||
case BOLD:
|
||||
return 1;
|
||||
case BOLD_ITALIC:
|
||||
return 3;
|
||||
case ITALIC:
|
||||
return 2;
|
||||
case NORMAL:
|
||||
return 0;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown enum value: " + this);
|
||||
}
|
||||
}
|
||||
238
src/org/oscim/theme/renderinstruction/Line.java
Normal file
238
src/org/oscim/theme/renderinstruction/Line.java
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
import org.oscim.theme.RenderThemeHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint.Cap;
|
||||
|
||||
/**
|
||||
* Represents a polyline on the map.
|
||||
*/
|
||||
public final class Line extends RenderInstruction {
|
||||
private static final Pattern SPLIT_PATTERN = Pattern.compile(",");
|
||||
|
||||
/**
|
||||
* @param line
|
||||
* ...
|
||||
* @param elementName
|
||||
* the name of the XML element.
|
||||
* @param attributes
|
||||
* the attributes of the XML element.
|
||||
* @param level
|
||||
* the drawing level of this instruction.
|
||||
* @param isOutline
|
||||
* ...
|
||||
* @return a new Line with the given rendering attributes.
|
||||
*/
|
||||
public static Line create(Line line, String elementName, Attributes attributes,
|
||||
int level, boolean isOutline) {
|
||||
String src = null;
|
||||
int stroke = Color.BLACK;
|
||||
float strokeWidth = 0;
|
||||
float[] strokeDasharray = null;
|
||||
Cap strokeLinecap = Cap.ROUND;
|
||||
int fade = -1;
|
||||
boolean fixed = false;
|
||||
String style = null;
|
||||
float blur = 0;
|
||||
|
||||
if (line != null) {
|
||||
fixed = line.fixed;
|
||||
fade = line.fade;
|
||||
strokeLinecap = line.cap;
|
||||
blur = line.blur;
|
||||
}
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
|
||||
if ("name".equals(name))
|
||||
style = value;
|
||||
else if ("src".equals(name)) {
|
||||
src = value;
|
||||
} else if ("stroke".equals(name)) {
|
||||
stroke = Color.parseColor(value);
|
||||
} else if ("width".equals(name)) {
|
||||
strokeWidth = Float.parseFloat(value);
|
||||
} else if ("stroke-dasharray".equals(name)) {
|
||||
strokeDasharray = parseFloatArray(value);
|
||||
} else if ("cap".equals(name)) {
|
||||
strokeLinecap = Cap.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
} else if ("fade".equals(name)) {
|
||||
fade = Integer.parseInt(value);
|
||||
} else if ("fixed".equals(name)) {
|
||||
fixed = Boolean.parseBoolean(value);
|
||||
} else if ("blur".equals(name)) {
|
||||
blur = Float.parseFloat(value);
|
||||
} else if ("from".equals(name)) {
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (line != null) {
|
||||
|
||||
strokeWidth = line.width + strokeWidth;
|
||||
if (strokeWidth <= 0)
|
||||
strokeWidth = 1;
|
||||
|
||||
return new Line(line, style, src, stroke, strokeWidth, strokeDasharray,
|
||||
strokeLinecap, level, fixed, fade, blur, isOutline);
|
||||
}
|
||||
|
||||
if (!isOutline)
|
||||
validate(strokeWidth);
|
||||
|
||||
return new Line(style, src, stroke, strokeWidth, strokeDasharray, strokeLinecap,
|
||||
level, fixed, fade, blur, isOutline);
|
||||
}
|
||||
|
||||
private static void validate(float strokeWidth) {
|
||||
if (strokeWidth < 0) {
|
||||
throw new IllegalArgumentException("width must not be negative: "
|
||||
+ strokeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
static float[] parseFloatArray(String dashString) {
|
||||
String[] dashEntries = SPLIT_PATTERN.split(dashString);
|
||||
float[] dashIntervals = new float[dashEntries.length];
|
||||
for (int i = 0; i < dashEntries.length; ++i) {
|
||||
dashIntervals[i] = Float.parseFloat(dashEntries[i]);
|
||||
}
|
||||
return dashIntervals;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private final int level;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// public final Paint paint;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final float width;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final boolean round;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final float color[];
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final boolean outline;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public final boolean fixed;
|
||||
|
||||
public final int fade;
|
||||
|
||||
public final String style;
|
||||
|
||||
public final Cap cap;
|
||||
|
||||
public final float blur;
|
||||
|
||||
private Line(String style, String src, int stroke, float strokeWidth,
|
||||
float[] strokeDasharray, Cap strokeLinecap, int level, boolean fixed,
|
||||
int fade, float blur, boolean isOutline) {
|
||||
super();
|
||||
|
||||
this.style = style;
|
||||
|
||||
// paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
//
|
||||
// if (src != null) {
|
||||
// Shader shader = BitmapUtils.createBitmapShader(src);
|
||||
// paint.setShader(shader);
|
||||
// }
|
||||
//
|
||||
// paint.setStyle(Style.STROKE);
|
||||
// paint.setColor(stroke);
|
||||
// if (strokeDasharray != null) {
|
||||
// paint.setPathEffect(new DashPathEffect(strokeDasharray, 0));
|
||||
// }
|
||||
// paint.setStrokeCap(strokeLinecap);
|
||||
|
||||
round = (strokeLinecap == Cap.ROUND);
|
||||
|
||||
this.cap = strokeLinecap;
|
||||
|
||||
color = new float[4];
|
||||
color[3] = (stroke >> 24 & 0xff) / 255.0f;
|
||||
color[0] = (stroke >> 16 & 0xff) / 255.0f * color[3];
|
||||
color[1] = (stroke >> 8 & 0xff) / 255.0f * color[3];
|
||||
color[2] = (stroke >> 0 & 0xff) / 255.0f * color[3];
|
||||
|
||||
this.width = strokeWidth;
|
||||
this.level = level;
|
||||
this.outline = isOutline;
|
||||
this.fixed = fixed;
|
||||
this.blur = blur;
|
||||
this.fade = fade;
|
||||
}
|
||||
|
||||
private Line(Line line, String style, String src, int stroke, float strokeWidth,
|
||||
float[] strokeDasharray, Cap strokeLinecap, int level, boolean fixed,
|
||||
int fade, float blur, boolean isOutline) {
|
||||
super();
|
||||
|
||||
this.style = style;
|
||||
|
||||
round = (strokeLinecap == Cap.ROUND);
|
||||
|
||||
color = line.color;
|
||||
|
||||
this.width = strokeWidth;
|
||||
this.level = level;
|
||||
this.outline = isOutline;
|
||||
this.fixed = fixed;
|
||||
this.fade = fade;
|
||||
this.cap = strokeLinecap;
|
||||
this.blur = blur;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
// renderCallback.renderWay(mPaint, mLevel, mColor, mStrokeWidth, mRound, mOutline);
|
||||
renderCallback.renderWay(this, level);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void scaleStrokeWidth(float scaleFactor) {
|
||||
// paint.setStrokeWidth(strokeWidth * scaleFactor);
|
||||
// }
|
||||
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
}
|
||||
93
src/org/oscim/theme/renderinstruction/LineSymbol.java
Normal file
93
src/org/oscim/theme/renderinstruction/LineSymbol.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
import org.oscim.theme.RenderThemeHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Represents an icon along a polyline on the map.
|
||||
*/
|
||||
public final class LineSymbol extends RenderInstruction {
|
||||
/**
|
||||
* @param elementName
|
||||
* the name of the XML element.
|
||||
* @param attributes
|
||||
* the attributes of the XML element.
|
||||
* @return a new LineSymbol with the given rendering attributes.
|
||||
* @throws IOException
|
||||
* if an I/O error occurs while reading a resource.
|
||||
*/
|
||||
public static LineSymbol create(String elementName, Attributes attributes)
|
||||
throws IOException {
|
||||
String src = null;
|
||||
boolean alignCenter = false;
|
||||
boolean repeat = false;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
|
||||
if ("src".equals(name)) {
|
||||
src = value;
|
||||
} else if ("align-center".equals(name)) {
|
||||
alignCenter = Boolean.parseBoolean(value);
|
||||
} else if ("repeat".equals(name)) {
|
||||
repeat = Boolean.parseBoolean(value);
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(elementName, src);
|
||||
return new LineSymbol(src, alignCenter, repeat);
|
||||
}
|
||||
|
||||
private static void validate(String elementName, String src) {
|
||||
if (src == null) {
|
||||
throw new IllegalArgumentException("missing attribute src for element: "
|
||||
+ elementName);
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean mAlignCenter;
|
||||
private final Bitmap mBitmap;
|
||||
private final boolean mRepeat;
|
||||
|
||||
private LineSymbol(String src, boolean alignCenter, boolean repeat)
|
||||
throws IOException {
|
||||
super();
|
||||
|
||||
mBitmap = BitmapUtils.createBitmap(src);
|
||||
mAlignCenter = alignCenter;
|
||||
mRepeat = repeat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
mBitmap.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderWaySymbol(mBitmap, mAlignCenter, mRepeat);
|
||||
}
|
||||
}
|
||||
144
src/org/oscim/theme/renderinstruction/PathText.java
Normal file
144
src/org/oscim/theme/renderinstruction/PathText.java
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
import org.oscim.theme.RenderThemeHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.FontMetrics;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.FloatMath;
|
||||
|
||||
/**
|
||||
* Represents a text along a polyline on the map.
|
||||
*/
|
||||
public final class PathText extends RenderInstruction {
|
||||
/**
|
||||
* @param elementName
|
||||
* the name of the XML element.
|
||||
* @param attributes
|
||||
* the attributes of the XML element.
|
||||
* @return a new PathText with the given rendering attributes.
|
||||
*/
|
||||
public static PathText create(String elementName, Attributes attributes) {
|
||||
String textKey = null;
|
||||
FontFamily fontFamily = FontFamily.DEFAULT;
|
||||
FontStyle fontStyle = FontStyle.NORMAL;
|
||||
float fontSize = 0;
|
||||
int fill = Color.BLACK;
|
||||
int stroke = Color.BLACK;
|
||||
float strokeWidth = 0;
|
||||
String style = null;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
if ("name".equals(name))
|
||||
style = value;
|
||||
else if ("k".equals(name)) {
|
||||
textKey = TextKey.getInstance(value);
|
||||
} else if ("font-family".equals(name)) {
|
||||
fontFamily = FontFamily.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
} else if ("font-style".equals(name)) {
|
||||
fontStyle = FontStyle.valueOf(value.toUpperCase(Locale.ENGLISH));
|
||||
} else if ("font-size".equals(name)) {
|
||||
fontSize = Float.parseFloat(value);
|
||||
} else if ("fill".equals(name)) {
|
||||
fill = Color.parseColor(value);
|
||||
} else if ("stroke".equals(name)) {
|
||||
stroke = Color.parseColor(value);
|
||||
} else if ("stroke-width".equals(name)) {
|
||||
strokeWidth = Float.parseFloat(value);
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(elementName, textKey, fontSize, strokeWidth);
|
||||
Typeface typeface = Typeface.create(fontFamily.toTypeface(), fontStyle.toInt());
|
||||
return new PathText(style, textKey, typeface, fontSize, fill, stroke, strokeWidth);
|
||||
}
|
||||
|
||||
private static void validate(String elementName, String textKey, float fontSize,
|
||||
float strokeWidth) {
|
||||
if (textKey == null) {
|
||||
throw new IllegalArgumentException("missing attribute k for element: "
|
||||
+ elementName);
|
||||
} else if (fontSize < 0) {
|
||||
throw new IllegalArgumentException("font-size must not be negative: "
|
||||
+ fontSize);
|
||||
} else if (strokeWidth < 0) {
|
||||
throw new IllegalArgumentException("stroke-width must not be negative: "
|
||||
+ strokeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
public final float fontSize;
|
||||
public final Paint paint;
|
||||
public Paint stroke;
|
||||
public String textKey;
|
||||
public final float fontHeight;
|
||||
public final float fontDescent;
|
||||
public String style;
|
||||
|
||||
private PathText(String style, String textKey, Typeface typeface, float fontSize,
|
||||
int fill, int outline, float strokeWidth) {
|
||||
super();
|
||||
|
||||
this.style = style;
|
||||
|
||||
this.textKey = textKey;
|
||||
|
||||
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setTextAlign(Align.CENTER);
|
||||
paint.setTypeface(typeface);
|
||||
paint.setColor(fill);
|
||||
|
||||
stroke = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
stroke.setStyle(Style.STROKE);
|
||||
stroke.setTextAlign(Align.CENTER);
|
||||
stroke.setTypeface(typeface);
|
||||
stroke.setColor(outline);
|
||||
stroke.setStrokeWidth(strokeWidth);
|
||||
|
||||
this.fontSize = fontSize;
|
||||
|
||||
paint.setTextSize(fontSize);
|
||||
stroke.setTextSize(fontSize);
|
||||
|
||||
FontMetrics fm = paint.getFontMetrics();
|
||||
fontHeight = FloatMath.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
|
||||
fontDescent = FloatMath.ceil(Math.abs(fm.descent));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderWayText(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scaleTextSize(float scaleFactor) {
|
||||
paint.setTextSize(fontSize * scaleFactor);
|
||||
stroke.setTextSize(fontSize * scaleFactor);
|
||||
}
|
||||
}
|
||||
65
src/org/oscim/theme/renderinstruction/RenderInstruction.java
Normal file
65
src/org/oscim/theme/renderinstruction/RenderInstruction.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
|
||||
/**
|
||||
* A RenderInstruction is a basic graphical primitive to draw a map.
|
||||
*/
|
||||
public abstract class RenderInstruction {
|
||||
/**
|
||||
* Destroys this RenderInstruction and cleans up all its internal resources.
|
||||
*/
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderCallback
|
||||
* a reference to the receiver of all render callbacks.
|
||||
* @param tags
|
||||
* the tags of the node.
|
||||
*/
|
||||
public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renderCallback
|
||||
* a reference to the receiver of all render callbacks.
|
||||
* @param tags
|
||||
* the tags of the way.
|
||||
*/
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the stroke width of this RenderInstruction by the given factor.
|
||||
*
|
||||
* @param scaleFactor
|
||||
* the factor by which the stroke width should be scaled.
|
||||
*/
|
||||
public void scaleStrokeWidth(float scaleFactor) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the text size of this RenderInstruction by the given factor.
|
||||
*
|
||||
* @param scaleFactor
|
||||
* the factor by which the text size should be scaled.
|
||||
*/
|
||||
public void scaleTextSize(float scaleFactor) {
|
||||
}
|
||||
}
|
||||
87
src/org/oscim/theme/renderinstruction/Symbol.java
Normal file
87
src/org/oscim/theme/renderinstruction/Symbol.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.theme.IRenderCallback;
|
||||
import org.oscim.theme.RenderThemeHandler;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Represents an icon on the map.
|
||||
*/
|
||||
public final class Symbol extends RenderInstruction {
|
||||
/**
|
||||
* @param elementName
|
||||
* the name of the XML element.
|
||||
* @param attributes
|
||||
* the attributes of the XML element.
|
||||
* @return a new Symbol with the given rendering attributes.
|
||||
* @throws IOException
|
||||
* if an I/O error occurs while reading a resource.
|
||||
*/
|
||||
public static Symbol create(String elementName, Attributes attributes)
|
||||
throws IOException {
|
||||
String src = null;
|
||||
|
||||
for (int i = 0; i < attributes.getLength(); ++i) {
|
||||
String name = attributes.getLocalName(i);
|
||||
String value = attributes.getValue(i);
|
||||
|
||||
if ("src".equals(name)) {
|
||||
src = value;
|
||||
} else {
|
||||
RenderThemeHandler.logUnknownAttribute(elementName, name, value, i);
|
||||
}
|
||||
}
|
||||
|
||||
validate(elementName, src);
|
||||
return new Symbol(src);
|
||||
}
|
||||
|
||||
private static void validate(String elementName, String src) {
|
||||
if (src == null) {
|
||||
throw new IllegalArgumentException("missing attribute src for element: "
|
||||
+ elementName);
|
||||
}
|
||||
}
|
||||
|
||||
private final Bitmap mBitmap;
|
||||
|
||||
private Symbol(String src) throws IOException {
|
||||
super();
|
||||
|
||||
mBitmap = BitmapUtils.createBitmap(src);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
mBitmap.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderPointOfInterestSymbol(mBitmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
|
||||
renderCallback.renderAreaSymbol(mBitmap);
|
||||
}
|
||||
}
|
||||
33
src/org/oscim/theme/renderinstruction/TextKey.java
Normal file
33
src/org/oscim/theme/renderinstruction/TextKey.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.theme.renderinstruction;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
||||
final class TextKey {
|
||||
static String getInstance(String key) {
|
||||
if (Tag.TAG_KEY_ELE.equals(key)) {
|
||||
return Tag.TAG_KEY_ELE;
|
||||
} else if (Tag.TAG_KEY_HOUSE_NUMBER.equals(key)) {
|
||||
return Tag.TAG_KEY_HOUSE_NUMBER;
|
||||
} else if (Tag.TAG_KEY_NAME.equals(key)) {
|
||||
return Tag.TAG_KEY_NAME;
|
||||
} else if (Tag.TAG_KEY_REF.equals(key)) {
|
||||
return Tag.TAG_KEY_REF;
|
||||
} else {
|
||||
throw new IllegalArgumentException("invalid key: " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user