Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
This commit is contained in:
@@ -2327,6 +2327,50 @@
|
||||
<!-- <area use="obj-area" repeat="false"></area>-->
|
||||
<!-- <symbol src="assets:omdb/icon_fill_area_3012.svg"></symbol>-->
|
||||
</m>
|
||||
<!-- 文字 -->
|
||||
<m v="OMDB_OBJECT_TEXT">
|
||||
<area use="obj-area" repeat="false" src="@text-src:textString" longEdge="t"></area>
|
||||
<!-- <m k="compliant" v="1">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#eccc68" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="2">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#ff7f50" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="3">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#ff6b81" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="4">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#a4b0be" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="5">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#57606f" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="6">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#7bed9f" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="7">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#70a1ff" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="8">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#5352ed" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="9">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#30336b" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="10">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#2c2c54" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="11">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#ff0000" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m k="compliant" v="12">-->
|
||||
<!-- <area use="obj-area" repeat="false" fill="#ff0000" longEdge="t"></area>-->
|
||||
<!-- </m>-->
|
||||
</m>
|
||||
<!-- 符号 -->
|
||||
<m v="OMDB_OBJECT_SYMBOL">
|
||||
<area use="obj-area" repeat="false" src="assets:omdb/tex_fill_area_3012.png" longEdge="t"></area>
|
||||
</m>
|
||||
|
||||
<!-- 人行横道 -->
|
||||
<m v="OMDB_CROSS_WALK">
|
||||
|
||||
@@ -64,6 +64,7 @@ enum class DataCodeEnum(var tableName: String, var code: String) {
|
||||
OMDB_SPEEDLIMIT_COND("条件点限速", "4003"),
|
||||
OMDB_SPEEDLIMIT_VAR("可变点限速", "4004"),
|
||||
OMDB_RESTRICTION("普通交限", "4006"),
|
||||
OMDB_WARNINGSIGN("警示信息", "4009"),
|
||||
OMDB_ELECTRONICEYE("电子眼", "4010"),
|
||||
OMDB_TRAFFICLIGHT("交通灯", "4022"),
|
||||
OMDB_TOLLGATE("收费站", "4023"),
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.source.MapLifeNiLocationTileSource
|
||||
import com.navinfo.collect.library.map.source.NavinfoMultiMapFileTileSource
|
||||
import com.navinfo.collect.library.map.source.NavinfoTileThemeHook
|
||||
import com.navinfo.collect.library.map.source.OMDBReferenceTileSource
|
||||
import com.navinfo.collect.library.map.source.OMDBTileSource
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
@@ -57,6 +58,8 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
|
||||
private val omdbTileSource by lazy { OMDBTileSource() }
|
||||
private val omdbReferenceTileSource by lazy { OMDBReferenceTileSource() }
|
||||
private val labelTileLoaderHook = LabelTileLoaderHook()
|
||||
private val navinfoTileThemeHook = NavinfoTileThemeHook()
|
||||
|
||||
init {
|
||||
initMap()
|
||||
@@ -76,7 +79,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
vectorNiLocationTileLayer = VectorTileLayer(mMapView.vtmMap, mapLifeNiLocationTileSource)
|
||||
|
||||
labelNiLocationLayer =
|
||||
LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, LabelTileLoaderHook())
|
||||
LabelLayer(mMapView.vtmMap, vectorNiLocationTileLayer, labelTileLoaderHook)
|
||||
|
||||
if (vectorNiLocationTileLayer != null) {
|
||||
addLayer(vectorNiLocationTileLayer, NIMapView.LAYER_GROUPS.BASE)
|
||||
@@ -114,7 +117,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
omdbReferenceLabelLayer = LabelLayer(
|
||||
mMapView.vtmMap,
|
||||
omdbReferenceTileLayer,
|
||||
LabelTileLoaderHook()
|
||||
labelTileLoaderHook
|
||||
)
|
||||
if (omdbReferenceTileLayer != null) {
|
||||
addLayer(omdbReferenceTileLayer, NIMapView.LAYER_GROUPS.VECTOR_TILE)
|
||||
@@ -127,7 +130,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
omdbLabelLayer = LabelLayer(
|
||||
mMapView.vtmMap,
|
||||
omdbVectorTileLayer,
|
||||
LabelTileLoaderHook()
|
||||
labelTileLoaderHook
|
||||
)
|
||||
if (omdbVectorTileLayer != null) {
|
||||
addLayer(omdbVectorTileLayer, NIMapView.LAYER_GROUPS.VECTOR_TILE)
|
||||
@@ -135,6 +138,9 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
|
||||
if (omdbLabelLayer != null) {
|
||||
addLayer(omdbLabelLayer, NIMapView.LAYER_GROUPS.LABEL)
|
||||
}
|
||||
// 向两个Vector图层增加hook钩子,加载数据前对style或数据进行二次处理
|
||||
omdbVectorTileLayer.addHook(navinfoTileThemeHook)
|
||||
omdbReferenceTileLayer.addHook(navinfoTileThemeHook)
|
||||
}
|
||||
|
||||
private fun resetOMDBVectorTileLayer() {
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.navinfo.collect.library.map.source;
|
||||
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.layers.tile.MapTile;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.renderer.bucket.RenderBuckets;
|
||||
import org.oscim.theme.styles.RenderStyle;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 数据在加载前对MapElement做处理
|
||||
*
|
||||
* */
|
||||
public class NavinfoTileThemeHook implements VectorTileLayer.TileLoaderThemeHook {
|
||||
// 缓存样式,如果存在相同的文字图片,从缓存直接获取
|
||||
private Map<String, RenderStyle> styleMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean process(MapTile tile, RenderBuckets buckets, MapElement element, RenderStyle style, int level) {
|
||||
// if (style instanceof AreaStyle) {
|
||||
// AreaStyle area = (AreaStyle) style;
|
||||
// if (area.src!=null&&area.texture==null) {
|
||||
// String textValue = null;
|
||||
// if (area.src.startsWith("@text-src:")) {
|
||||
// String tagKey = area.src.replace("@text-src:", "");
|
||||
// // 根据配置的tagKey获取对应的文字值
|
||||
// textValue = element.tags.getValue(tagKey);
|
||||
// } else if (area.src.startsWith("@text:")) {
|
||||
// // 构建一个文字图片
|
||||
// textValue = area.src.substring(5);
|
||||
// }
|
||||
//
|
||||
// // 使用文本值生成纹理图片
|
||||
// if (textValue==null) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // 根据引用字段,生成新的style样式
|
||||
// RenderStyle cacheStyle = styleMap.get(textValue);
|
||||
// if (cacheStyle!=null) {
|
||||
// style.set(cacheStyle);
|
||||
// } else { // 不存在缓存style,需要按照文字生成对应的图片纹理
|
||||
// AreaStyle.AreaBuilder<?> builder = new AreaStyle.AreaBuilder();
|
||||
// builder.set((AreaStyle) style);
|
||||
// // 构建一个文字图片
|
||||
// Canvas canvas = CanvasAdapter.newCanvas();
|
||||
// Paint paint = CanvasAdapter.newPaint();
|
||||
// paint.setColor(Color.WHITE);
|
||||
// paint.setTextSize(15);
|
||||
//
|
||||
// Bitmap bitmap = CanvasAdapter.newBitmap(Math.round(paint.getTextWidth(textValue)+10), Math.round(paint.getTextHeight(textValue)+10), 0);
|
||||
// canvas.setBitmap(bitmap);
|
||||
// canvas.drawText(textValue, 5
|
||||
// , 5+paint.getTextHeight(textValue), paint, paint);
|
||||
// builder.texture = new TextureItem(Utils.potBitmap(bitmap), area.repeat);
|
||||
// builder.src = null; // 清空原有的带@的src配置
|
||||
// area = builder.build();
|
||||
// styleMap.put(textValue, area);
|
||||
// style.set(area);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// style.update();
|
||||
return false; // 如果返回true,后续的hook将不会执行
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(MapTile tile, boolean success) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user