4) run OsmandMapCreator to create an OBF file from the above created OSM file (note that OMC does not handle relations. So you'll have to cut and paste in the OSM file);
5) select your rendering file in Osmand.
Mine looks as follows, designed to render the nature of cadastral parcels. Copy such 'custom.render.xml' file to the rendering dir on your Android device (android/data/net.osmand.plus/files/rendering):
<renderingStyle name="NewPaPoPCn" depends="default" defaultColor="#F5FFFF" version="1">
<renderingAttribute name="shadowRendering">
<!-- 0 - no shadow, 1 - one step, 2 - blur shadow, 3 - solid shadow -->
<!-- next line corrects for shadowColor appearing very dark with solid shadow in day view, bridges would not stand out -->
<filter minzoom="12" nightMode="false" attrIntValue="3" shadowColor="#888888"/>
<filter minzoom="12" attrIntValue="3" shadowColor="#888888"/>
<!-- next line avoids melting close-together highways into one another - disadvantage is separator lines between segments and at intersections -->
<filter minzoom="9" maxzoom="14" attrIntValue="3" shadowColor="#9e9e9e"/>
<!-- appearance equivalents: one-step #464646 equals solid #767676 -->
<!-- filter minzoom="9" maxzoom="13" attrIntValue="3" shadowColor="#767676"/ -->
<filter attrIntValue="0"/>
</renderingAttribute>
<renderingAttribute name="polygonMinSizeToDisplay">
<!-- Minimum polygon size in pixels -->
<filter attrIntValue="4"/>
</renderingAttribute>
<order>
<!-- Point -->
<switch objectType="1" order="128">
</switch>
<!-- Polygon -->
<switch objectType="3">
<case tag="boundary" value="cadastral" order="50"/>
</switch>
<!-- Line -->
<switch objectType="2">
<filter tag="highway" value="track" order="52"/>
<filter tag="highway" value="path" order="51"/>
</switch>
</order>
<text>
<group>
<filter tag="boundary" value="cadastral" textOrder="8"/>
<groupFilter textOnPath="true">
<filter minzoom="12" textColor="#202020" textHaloColor="#ffffff" textHaloRadius="1" textWrapWidth="12" textMinDistance="1" textSize="12"/>
</groupFilter>
</group>
</text>
<point>
</point>
<polygon>
<case minzoom="12" tag="boundary" value="cadastral" color="#55cccccc" color_2="#101010" strokeWidth_2="0.5"> <!-- Parcelle cadastrale -->
<apply_if additional="papo:pc_styln=0" color="#70ffffc0"/> <!-- Sols, jardins, etc. -->
<apply_if additional="papo:pc_styln=1" color="#ff80c080"/> <!-- Bois -->
<apply_if additional="papo:pc_styln=2" color="#70ffc0ff" shader="quarry2"/> <!-- Carri?res -->
<apply_if additional="papo:pc_styln=3" color="#70dedede"/> <!-- Chemins de fer, -->
<apply_if additional="papo:pc_styln=4" color="#700080ff"/> <!-- Eaux -->
<apply_if additional="papo:pc_styln=5" color="#ffe0c0ff"/> <!-- Landes -->
<apply_if additional="papo:pc_styln=6" color="#ffc0ffc0"/> <!-- Pr?s -->
<apply_if additional="papo:pc_styln=7" color="#70ff8000"/> <!-- Terrains ? b?tir -->
<apply_if additional="papo:pc_styln=8" color="#fff2d098"/> <!-- Terres -->
<apply_if additional="papo:pc_styln=9" color="#70ffffff" shader="orchard"/> <!-- Vergers, vignes -->
<apply_if additional="papo:pc_styln=10" color="#ffff8080"/> <!-- Mixte (j, k, etc.) -->
</case>
</polygon>
<line>
</line>
</renderingStyle>
2) Translation file? Mine looks as follows:
# -*- coding: utf-8 -*-
'''
Translation file to convert Parcelles & Polygones' shapefiles to OSM format.
The shapefile contains cadastral parcels shapes + attributes
boundary:administrative
admin_level: 12? (11 section?)
Tag translation
The DBF file contains :
PC_ID=Identifiant
PC_LABEL=Etiquette
...
PC_SURFM= Contenance cadastrale
PC_SURFV=Contenance calculée (ie <> contenance matrice cadastrale) exprimée en hectares
PC_PERIM=Périmètre exprimé en mètres
PC_STYLN=Index nature de culture (cf. PaPoPCn.render.xml)
...
PC_REM=Remarque(s)
etc.
'''
import re
def filterTags(attrs):
if not attrs: return
tags = {}
tags.update({'boundary':'cadastral'})
tags.update({'admin_level':'12'})
tags.update({'name':attrs['PC_LABEL']})
tags.update({'area':attrs['PC_SURFM']})
tags.update({'PaPo:Type':'PC'})
tags.update({'PaPo:PC_ID':attrs['PC_ID']})
tags.update({'PaPo:PC_LABEL':attrs['PC_LABEL']})
tags.update({'PaPo:PC_INSEE':attrs['PC_CODCO']})
tags.update({'PaPo:PC_SECF':attrs['PC_SECF']})
tags.update({'PaPo:PC_NUM':attrs['PC_NUM']})
tags.update({'PaPo:PC_SURFM':attrs['PC_SURFM']})
tags.update({'PaPo:PC_SURFV':attrs['PC_SURFV']})
tags.update({'PaPo:PC_NATUR':attrs['PC_NATUR']})
tags.update({'PaPo:PC_STYLN':attrs['PC_STYLN']})
tags.update({'PaPo:PC_STYLP':attrs['PC_STYLP']})
tags.update({'Source':'Parcelles et Polygones SARL - DGFIP'})
return tags;
3) run some ogr2osm python command?
My BATfile looks as follows:
REM Attn au "code page" du fichier DBF. Ouvrir fichier avec DBF Commander - Tools - Set Code Page : 850
REM et vérifier que les fichiers de commandes python (ogr2osm.py et geom.py) sont dans le répertoire prévu (D:\PaPo\OSGeo4W64\bin\ ou E:\ANTEC\PaPo\OSGeo4W64\bin\)
REM Ensuite, avec OsmAndMapCreator, création du fichier *.OBF
REM Attention OsmAndMapCreator ne gère pas les tags "relation" ... Copier-Coller des données listées ("outer") dans la balise <way id dont la référence est indiquée dans la balise <member ref de la balise <relation id...
REM --epsg:
REM EPSG 27561 = Lambert I, 27571 = Lambert Zone 1 (Nord)
REM EPSG 27562 = Lambert II, 27572 = Lambert Zone 2 (Centre) (= II Etendu)
REM EPSG 27563 = Lambert III, 27573 = Lambert Zone 3 (Sud)
REM EPSG 27564 = Lambert IV, 27574 = Lambert Zone 4 (Corse)
REM EPSG 2154 = Lambert93
REM EPSG 3942:3950 = CC42:CC50
:: Chargement OSGeo4W (ie GDAL/OGR)
@TITLE Conversion format fichier SHP vers OSM - SHP2OSM
@ECHO OFF
call o4w_env.bat
IF ERRORLEVEL 1 GOTO :ERROR_OSGEO4W
:: Création fichier *.OSM
python "E:\ANTEC\PaPo\OSGeo4W64\bin\ogr2osm.py" -f -o "41-La Girolliere_PCn.osm" --positive-id --no-upload-false --add-version -t "\translations\NewPCn.py" -v --epsg=2154 ..\shp\PC_202001.shp
IF ERRORLEVEL 1 GOTO :ERROR_OGR2OSM
GOTO :EOF
::::::::::::
:::: ERREURS
::::::::::::
:ERROR_OSGEO4W
ECHO ERROR_OSGEO4W - Erreur lors de la configuration de l'environnement GDAL/OGR.
PAUSE
GOTO :EOF
:ERROR_OGR2OSM
ECHO ERROR_OGR2OSM - Erreur lors de la conversion de format du fichier.
PAUSE
GOTO :EOF
:EOF
ECHO ON
4) run OsmandMapCreator to create an OBF file, then copy it to your Android device (android/data/net.osmand.plus/files).
5) Custom renderer selection:
Menu-Configure map-Map style: custom rendering file.
For sure all this can be done in a more elegant way...
I hope this helps!
Regards,
Philippe