次に、レイヤーの renderer-example.partition に OLP CLI を設定します。に renderer-example.partition は、次の地理座標を持つ protobuf シリアル化データが含まれています Golden Gate Bridge in San Francisco。
シリアル番号付き
"lat":37.82171"lon": -122.47881
"hint":"Golden Gate Bridge in San Francisco"
proto データをシリアル化するには _java 、または _scala バインディングを次のように使用します。
Java
Scala
File serializedProto = new File("serializedProto.txt");
serializedProto.createNewFile();
Render.MainProtobufMessage.newBuilder()
.setLon(13)
.setLat(52)
.setHint("Golden Gate Bridge in San Francisco")
.build().writeTo(Files.newOutputStream(serializedProto.toPath()));
val serializedProto = new File("serializedProto.txt")serializedProto.createNewFileRender.MainProtobufMessage.newBuilder
.setLon(-122.47881)
.setLat(37.82171)
.setHint("Golden Gate Bridge in San Francisco")
.build.writeTo(Files.newOutputStream(serializedProto.toPath))
パーティション をレイヤーにアップロードするには、次の OLP CLI コマンドを実行します。
olp catalog layer partition put hrn:here:data::realm:renderer-tutorial-catalog renderer-layer --partitions=19319036:renderer-example.partition
OLP CLI は次の出力を返します。
100% [===========================================================]1/1 (0:00:00 / 0:00:00)
Partition 19319036 was successfully uploaded.
/**
* Renderer plugin to convert JSON data to GeoJSON.
*
* Generated GeoJSON must be created according to GeoJSON Specification:
* https://tools.ietf.org/html/rfc7946
*
* This template is an example of plugin to generate the GeoJSON object based on decoded partition
* content (the same data structure as in Decoded Data panel).
*
* Renderer plugin must return an object with one of these functions in it:
*
*
* getGeoJSON: function (params) { ... }
* getGeoJSONAsync: async function (params) { ... }
*
*
* Both synchronous `getGeoJSON` and asynchronous `getGeoJSONAsync` functions return
* an object with GeoJSON data in property `body`:
*
* {
* contentType: "application/geo+json; charset=utf-8",
* body: geoJsonData
* }
*
*
* Only one of these functions must be declared, if both are present plugin will not be used.
*/(()=>{"use strict";/** @type {RendererPlugin} */const plugin ={/**
* Generates object with GeoJSON data.
*
* @param {object} params.logger Logger to log information to console.
* @param {object} params.layer All properties as well as dataUrl, name, partitioning and
* originalConfiguration.
* @param {object} params.decodeResult Decoded data of the partition.
* @param {object} params.mapUtils Various converters like `mercatorConverter`,
* `heretileToQuad`, `hdmapCoordinateToLonLat`, etc.
* @param {object} params.geometryDataProviders Various geometry data providers to map data.
* @returns {object} An object with generated GeoJSON data.
*/getGeoJSON:function(params){// Implement either this or `getGeoJSONAsync` function.// See more detailed description in the header of this file.// By default, logger will display only messages of `warn` and `error` levels.// To enable all of them, set level to `0`.const logger = params.logger;
logger.level =0;
logger.info(`Creating GeoJSON for tile ${params.decodeResult.partitionId}`);// To debug plugin, put a `debugger` keyword and activate browser's developer tools.// Dev tools will activate a breakpoint at each occurrence of `debugger` keyword:// debugger;// Returning sample empty GeoJSON objectreturn{
contentType:"application/geo+json; charset=utf-8",
body:{// Add your GeoJSON features here"type":"FeatureCollection","features":[]}}}};return plugin;})();
// Prepare GeoJSON to visualizevar result ={"type":"FeatureCollection","features":[{"type":"Feature","properties":{"tooltip": data.hint
},"geometry":{"type":"Point","coordinates":[
data.lon,
data.lat
]}}]};
更新された JavaScript ファイルは次のようになります。
(()=>{"use strict";const plugin ={getGeoJSON:function(params){// Destructuring of the `params` object.const{logger, decodeResult }= params;// Partition data decoded with the schema protobufvar data = decodeResult.data;
logger.info("Data successfully loaded");// Prepare GeoJSON to visualizevar result ={"type":"FeatureCollection","features":[{"type":"Feature","properties":{"tooltip": data.hint
},"geometry":{"type":"Point","coordinates":[
data.lon,
data.lat
]}}]};// Return an object with GeoJSON datareturn{
contentType:"application/vnd.geo+json; charset=utf-8",
body: result
};}};return plugin;})();
(()=>{"use strict";const plugin ={getGeoJSON:function(params){const{logger, decodeResult }= params;var data = decodeResult.data;
logger.info("Data successfully loaded");var result ={"type":"FeatureCollection","features":[{"type":"Feature","properties":{"tooltip": data.hint
},"geometry":{"type":"Point","coordinates":[
data.lon,
data.lat
]}}]};// DEBUGGER: Application will stoped at this linedebugger;// DEBUGER: Application will stoped at this linereturn{
contentType:"application/vnd.geo+json; charset=utf-8",
body: result
};}};return plugin;})();