2013-06-05 2 views
12

私は円がサポートされていることがわかりにGeoJSONのスペックアップ見て:私はしかし、それは私にエラーを与えるgeojsonlint(http://geojsonlint.com/)内のコードを実行しようとするとgeojsonサークル、サポートされているかどうか

http://geopriv.dreamhosters.com/geojson/geojson-spec.html#circleExample

を。

入力:

{ 
"type": "Circle", 
"coordinates": [4.884, 52.353], 
"radius": 200 
} 

は与える:

"Circle" is not a valid GeoJSON type. 

を私はD3を使って、マップ上の影響範囲と利害の異なる場所を示したいと思います。入力にはGeoJsonが必要ですが、GeoJsonではサークルはサポートされていません。

+0

あなたは 'L.Circle.toGeoJSON()'ポイントが円として表現されなければならないことを示すために追加のプロパティを追加するには上書きcaould:がhttps://github.com/Leaflet/Leaflet/issues/2888をそれは標準ではなく、サークルとして表現するためのメタデータを提供します。 –

+0

ああ、それはリーフレットのAPIを使って解決します。これは機能しますが、あなたはgeojson自体を使用していないでしょう、あなたはリーフレットがあなたに与える機能を使用しています。 D3は、使用するマッピングライブラリとは独立した同様のソリューションを提供します。 – cantdutchthis

答えて

19

私は円が彼らではない

をサポートしていることがわかりにGeoJSONのスペックを調べます。偽の、または間違った仕様を見つけることができたようです。 geojson.orgにアクセスしてspecsを探してください。サークルについては何もありません。

+1

彼は、https://github.com/geojson/geojson-spec/issues/1やhttps://github.com/geojson/geojson-spec/wiki/Proposal--のようなドラフトや提案で何かを見つけたと思います。 Circles-and-Ellipses-Geoms –

2

にGeoJSON、 からの円のサポートがありますが、

"geometry": { 
     "type": "LineString", 
     "coordinates": [ 
        [center_X, center_y], 
        [center_X, center_y] 
       ] 
     } 
then set the dynamic style use radius as the strokeweight 
function featureStyle(feature){ 
    return { 
     strokeWeight: radius, 
    }; 
    } 

それは、地図上の円のように見えるオブジェクトgeiometryラインストリングを使用して、円

をシミュレートするために、ラインストリングを使用することができます。

+0

また、 'Point'で行うことができます、私はかなり確信しています... –

-1
A circle... some code I use for making a circle for an OpenStreetMap 

-- x is decimal latitude 
-- y is decimal longitude 
-- r is radius -- .00010 is about 40m in OSM (3 about 50km) 

-- Adjust for map latitude distortion further north or south 

x = math.log(math.tan((90 + x) * math.pi/360))/(math.pi/180) 

-- For loop to gather all the points of circle here 1 to 360 
-- can also use the for loop to make some other interesting shapes 

for i = 1, 360 do 
    angle = i * math.pi/180 
    ptx = x + r * math.cos(angle) 
    pty = y + r * math.sin(angle) 

-- readjust latitude for map distortion 

    ptx = 180/math.pi * (2 * math.atan(math.exp(ptx * math.pi/180)) - math.pi/2) 

-- Build an array of positions for GeoJSON - formatted lat and long 

    data[i] = '[' .. string.format("%.6f",pty) .. "," 
    data[i] = data[i] .. string.format("%.6f",ptx) .. ']' 

-- End of for loop 
end 

-- Cycle through the data array with another for loop to build the 
    coordinates (put in brackets and commas etc. for the actual 
    GeoJSON coordinates string. Add data[1] to the end to close 
    the polygon (circle). A circle. 

-- If you want a solid circle then use fill and a hex color 
-- If you want a LineString just make fill invisible or #ffffff 
     Include the stroke-width and stroke-color parameters as well. 
-- If latitude is greater than 89.5 or less than -89.5 you may wish 
    to cut off the circle by drawing a line at polar regions by using 
    those latitudes. 
-- I use this simply for several circles and not for hundreds of them. 

Cheers! 
-- 
+2

ようこそ!この質問は2013年(4年前)の日付です。もちろん、あなたはまだ古い投稿に答えることができますが、その場合、答えが以前のものよりも優れている理由を必ず強調してください。これは新しい技術、図書館などのおかげです。この特定のケースでは、あなたの投稿が質問に対する答えを提供しているかどうかはわかりません。円を描く方法ではなく、円のメタデータがGeoJSONフォーマット。 – ghybs

関連する問題