GeoJSON feature & Mapbox segments
GeoJSON feature & Mapbox segments



custom JSON format ???
{
    "rows": [],
    "props": {
        "labelPoint": {
            "x": 93.5,
            "y": 68.0291
        },
        "type": "",
        "fill": "#ffffff"
    },
    "_type": "",
    "graphType": "Polygon",
    "graph": {
        "points": [
            {
                "x": 93.5,
                "y": 2
            },
            {
                "x": 182.4238,
                "y": 52.4418
            },
            {
                "x": 148.4579,
                "y": 134.0582
            },
            {
                "x": 38.5421,
                "y": 134.0582
            },
            {
                "x": 4.5762,
                "y": 52.4418
            }
        ],
        "segments": [
            {
                "p1": {
                    "x": 93.5,
                    "y": 2
                },
                "p2": {
                    "x": 182.4238,
                    "y": 52.4418
                },
                "line": {
                    "k": 0.5672474635586874,
                    "b": -51.03763784273727,
                    "x": null
                }
            },
            {
                "p1": {
                    "x": 182.4238,
                    "y": 52.4418
                },
                "p2": {
                    "x": 148.4579,
                    "y": 134.0582
                },
                "line": {
                    "k": -2.4028923125840915,
                    "b": 490.7865466523778,
                    "x": null
                }
            },
            {
                "p1": {
                    "x": 148.4579,
                    "y": 134.0582
                },
                "p2": {
                    "x": 38.5421,
                    "y": 134.0582
                },
                "line": {
                    "k": 0,
                    "b": 134.0582,
                    "x": null
                }
            },
            {
                "p1": {
                    "x": 38.5421,
                    "y": 134.0582
                },
                "p2": {
                    "x": 4.5762,
                    "y": 52.4418
                },
                "line": {
                    "k": 2.402892312584092,
                    "b": 41.44568419915268,
                    "x": null
                }
            },
            {
                "p1": {
                    "x": 4.5762,
                    "y": 52.4418
                },
                "p2": {
                    "x": 93.5,
                    "y": 2
                },
                "line": {
                    "k": -0.5672474635586874,
                    "b": 55.03763784273727,
                    "x": null
                }
            }
        ],
        "segmentNum": 0,
        "middleLine": null,
        "fill": "#ffffff"
    },
    "fill": "#ffffff"
}
geojson-segment
split a geojson file generated by togeojson into two-vertex chunks with properties
$ npm i -S @mapbox/geojson-segment
https://github.com/mapbox/geojson-segment
mapbox demo
https://docs.mapbox.com/mapbox-gl-js/example/data-driven-lines/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Style lines with a data-driven property</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.8.1/mapbox-gl.css" rel="stylesheet" />
<style>
	body { margin: 0; padding: 0; }
	#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
	mapboxgl.accessToken = 'pk.eyJ1IjoieGdxZnJtcyIsImEiOiJjaXNtbmVrNWMwMW9lMnFteHJlN2M4NWU1In0.USVUsZvLCNUF1dNVuZsO5g';
    var map = new mapboxgl.Map({
        container: 'map',
        style: 'mapbox://styles/mapbox/streets-v11',
        center: [-122.48383155304096, 37.82882682974591],
        zoom: 16
    });
    map.on('load', function() {
        map.addSource('lines', {
            'type': 'geojson',
            'data': {
                'type': 'FeatureCollection',
                'features': [
                    {
                        'type': 'Feature',
                        'properties': {
                            'color': '#F7455D' // red
                        },
                        'geometry': {
                            'type': 'LineString',
                            'coordinates': [
                                [-122.4833858013153, 37.829607404976734],
                                [-122.4830961227417, 37.82932776098012],
                                [-122.4830746650696, 37.82932776098012],
                                [-122.48218417167662, 37.82889558180985],
                                [-122.48218417167662, 37.82890193740421],
                                [-122.48221099376678, 37.82868372835086],
                                [-122.4822163581848, 37.82868372835086],
                                [-122.48205006122589, 37.82801003030873]
                            ]
                        }
                    },
                    {
                        'type': 'Feature',
                        'properties': {
                            'color': '#33C9EB' // blue
                        },
                        'geometry': {
                            'type': 'LineString',
                            'coordinates': [
                                [-122.48393028974533, 37.829471820141016],
                                [-122.48395174741744, 37.82940826466351],
                                [-122.48395174741744, 37.829412501697064],
                                [-122.48423874378203, 37.829357420242125],
                                [-122.48422533273697, 37.829361657278575],
                                [-122.48459815979002, 37.8293425906126],
                                [-122.48458743095398, 37.8293447091313],
                                [-122.4847564101219, 37.82932776098012],
                                [-122.48474299907684, 37.829331998018276],
                                [-122.4849334359169, 37.829298101706186],
                                [-122.48492807149889, 37.82930022022615],
                                [-122.48509705066681, 37.82920488676767],
                                [-122.48509168624878, 37.82920912381288],
                                [-122.48520433902739, 37.82905870855876],
                                [-122.48519897460936, 37.82905870855876],
                                [-122.4854403734207, 37.828594749716714],
                                [-122.48543500900269, 37.82860534241688],
                                [-122.48571664094925, 37.82808206121068],
                                [-122.48570591211319, 37.82809689109353],
                                [-122.4858346581459, 37.82797189627337],
                                [-122.48582661151886, 37.82797825194729],
                                [-122.4859634041786, 37.82788503534145],
                                [-122.48595803976059, 37.82788927246246],
                                [-122.48605459928514, 37.82786596829394]
                            ]
                        }
                    }
                ]
            }
        });
        map.addLayer({
            'id': 'lines',
            'type': 'line',
            'source': 'lines',
            'paint': {
                'line-width': 3,
                // Use a get expression (https://docs.mapbox.com/mapbox-gl-js/style-spec/#expressions-get)
                // to set the line-color to a feature property value.
                'line-color': ['get', 'color']
            }
        });
    });
</script>
</body>
</html>
toFixed

x = "-100";
"-100"
"-100"
+x;
-100

x = -100;
-100
+x.toFixed(4);
-100
x = -100.000000001;
-100.000000001
+x.toFixed(4);
-100
x = 100.00111;
100.00111
+x.toFixed(4);
100.0011
x = -100.00111;
-100.00111
+x.toFixed(4);
-100.0011
GeoJSON feature & Mapbox segments的更多相关文章
- php请求返回GeoJSON格式的数据
		
<?php /* * Following code will list all the products */ // array for JSON response $response = ar ...
 - Geotools操作GeoJSON:解析FeatureCollection对象文件
		
Geotools操作GeoJSON:解析FeatureCollection对象文件 一.解析FeatureCollection对象文件 1.1 geotools操作GeoJSON过程中的问题及相关源码 ...
 - GeoJson的生成与解析,JSON解析,Java读写geojson,geotools读取shp文件,Geotools中Geometry对象与GeoJson的相互转换
		
GeoJson的生成与解析 一.wkt格式的geometry转成json格式 二.json格式转wkt格式 三.json格式的数据进行解析 四.Java读写geojson 五.geotools读取sh ...
 - Vector Tile
		
Mapbox Vector Tile Specification A specification for encoding tiled vector data. <?XML:NAMESPACE ...
 - leaflet地图库
		
an open-source JavaScript libraryfor mobile-friendly interactive maps Overview Tutorials Docs Downlo ...
 - Leaflet_创建地图(官网示例,可以直接运行)(2017-10-20)
		
官网:http://leafletjs.com/examples.html 快速启动指南 http://leafletjs.com/examples/quick-start/example.html ...
 - Go 语言相关的优秀框架,库及软件列表
		
If you see a package or project here that is no longer maintained or is not a good fit, please submi ...
 - Awesome Go精选的Go框架,库和软件的精选清单.A curated list of awesome Go frameworks, libraries and software
		
Awesome Go financial support to Awesome Go A curated list of awesome Go frameworks, libraries a ...
 - 矢量切片(Vector tile)番外一:Proj4js
		
说明:番外篇是对正篇矢量切片(Vector tile)中提到的一些值得继续延伸的关注点继续进行探索和学习,所涉及的内容以解决实际问题为主要导向. 一.新的需求? 在完成了矢量切片的工作后,新的需求出现 ...
 
随机推荐
- Windows10 通过 ssh 映射 Linux 为盘符
			
一. 安装WinFsp 地址 选择.msi文件下载并安装 二. 安装SSHFS-Win 地址 点击下载64位安装包, 然后安装 三.挂载Linux文件夹 1.映射网络驱动器 输入用户名, 服务器ip地 ...
 - linux:nginx
			
nginx介绍 一个高性能的http服务器/反向代理服务器及电子邮件代理服务器 nginx 大致有三大功能(静态web服务器.反向代理.负载均衡) nginx一般同时做为静态web服务器和反向代理服务 ...
 - 最简单直接地理解Java软件设计原则之单一职责原则
			
理论性知识 定义 单一职责原则, Single responsibility principle (SRP): 一个类,接口,方法只负责一项职责: 不要存在多余一个导致类变更的原因: 优点 降低类的复 ...
 - EasyConnect连接成功后,虚拟ip地位未分配
			
文章目录 #问题描述: 今天公司做项目,连接上EasyConnect以后,显示连接成功,但是虚拟ip地址未分配,导致无法远程连接数据库,以及svn无法更新项目. #解决办法: 百度网上各种解决办法,没 ...
 - 数据库备份和恢复---MariaDB
			
定义 数据备份:将源数据再次存储到新的位置 数据恢复:将备份好的数据重新应用到数据库系统 常见的备份类型: 按照是否备份整个数据集来分 完全备份:备份从开始到执行备份这一时刻的所有数据集 增量备份:备 ...
 - python--函数、参数、名称空间与作用域、匿名函数、内置函数、闭包
			
python函数 函数定义 def welcome(): print('hello world!!') welcome() #函数调用 ...运行结果 hello world!! 函数定义和编写原则: ...
 - Jenkins Pipelines+Docker执行RobotFramework自动化测试
			
一.Jenkins Pipelines介绍 Pipeline,简而言之,就是一套运行于Jenkins上的工作流框架,将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程编排与 ...
 - Java并发包源码学习系列:基于CAS非阻塞并发队列ConcurrentLinkedQueue源码解析
			
目录 非阻塞并发队列ConcurrentLinkedQueue概述 结构组成 基本不变式 head的不变式与可变式 tail的不变式与可变式 offer操作 源码解析 图解offer操作 JDK1.6 ...
 - HDU6311 Cover【欧拉路径 | 回路】
			
HDU6311 Cover 题意: 给出\(N\)个点的简单无向图,不一定联通,现在要用最少的路径去覆盖所有边,并且每条边只被覆盖一次,问最少路径覆盖数和各条路径 \(N\le 10^5\) 题解: ...
 - 第 45 届国际大学生程序设计竞赛(ICPC)亚洲网上区域赛模拟赛. A.Easy Equation  (前缀和/差分)
			
题意:RT,给你四个数\(a,b,c,d\),求\(x+y+z=k\)的方案数. 题解:我们可以先枚举\(x\)的值,然后\(x+y\)能取到的范围一定是\([x,x+b]\),也就是说这个区间内每个 ...