2013-06-05 7 views
12

जब मैं GeoJSON का चश्मा ऊपर देखो मुझे लगता है कि हलकों समर्थित हैं:geojson सर्कल, समर्थित या नहीं?

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

जब मैं geojsonlint (http://geojsonlint.com/) में कोड की कोशिश तथापि, यह मुझे एक त्रुटि देता है।

इनपुट:

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

देता है:

"Circle" is not a valid GeoJSON type. 

मैं d3 का उपयोग करके एक नक्शे पर प्रभाव की दूरी के साथ हितों के विभिन्न स्थानों दिखाना चाहते हैं। इसे इनपुट के लिए जियोजसन की आवश्यकता है लेकिन यह सच है कि सर्किल जियोज़सन के साथ समर्थित नहीं हैं?

+0

आप 'ओवरराइड caould L.Circle.toGeoJSON()' संकेत मिलता है कि प्वाइंट एक चक्र के रूप में प्रतिनिधित्व किया जाना चाहिए अतिरिक्त गुण जोड़ने के लिए: https://github.com/Leaflet/Leaflet/issues/2888 हालांकि यह मानक नहीं है, यह आपको सर्कल के रूप में प्रतिनिधित्व करने के लिए मेटाडेटा देता है। –

+0

आह हाँ, लेकिन यह पत्रक एपीआई का उपयोग करके हल किया जाएगा। यह काम करेगा लेकिन आप geojson प्रति से उपयोग नहीं करेंगे, आप उस कार्यक्षमता का उपयोग करेंगे जो पुस्तिका आपको देता है। डी 3 एक समान समाधान प्रदान करेगा जो आपके द्वारा उपयोग की जाने वाली मानचित्रण लाइब्रेरी से स्वतंत्र है। – cantdutchthis

उत्तर

19

जब मैं GeoJSON का चश्मा ऊपर देखो मुझे लगता है कि हलकों का समर्थन कर रहे

वे नहीं कर रहे हैं देखते हैं। ऐसा लगता है कि आप कुछ नकली या गलत चश्मा ढूंढने में कामयाब रहे। specs खोजने के लिए geojson.org पर जाएं, मंडलियों के बारे में कुछ भी नहीं है।

+1

मुझे लगता है कि उसे ड्राफ्ट या प्रस्तावों में कुछ मिला है जैसे https://github.com/geojson/geojson-spec/issues/1 या https://github.com/geojson/geojson-spec/wiki/Proposal--- मंडल-और-एलिप्स-जियोम्स –

2

GeoJSON, से कोई चक्र समर्थन लेकिन आप LineString उपयोग कर सकते हैं एक चक्र

अनुकरण करने के लिए एक LineString का उपयोग geiometry आपत्ति

"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, 
    }; 
    } 

यह मानचित्र पर एक चक्र की तरह दिखता है।

+0

'प्वाइंट' के साथ भी किया जा सकता है, मुझे पूरा यकीन है ... –

-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

SO में आपका स्वागत है! कृपया ध्यान दें कि 2013 से यह प्रश्न दिनांक (4 साल पहले!)। बेशक आप अभी भी पुरानी पोस्ट का जवाब दे सकते हैं, लेकिन उस स्थिति में यह सुनिश्चित करना सुनिश्चित करें कि आपका उत्तर पिछले की तुलना में बेहतर क्यों है। यह नई तकनीक, लाइब्रेरी इत्यादि के लिए धन्यवाद हो सकता है। इस विशिष्ट मामले में, मुझे यकीन नहीं है कि आपकी पोस्ट प्रश्न का उत्तर प्रदान करती है: बिंदु यह नहीं है कि सर्कल कैसे खींचना है, लेकिन यदि सर्कल मेटाडाटा GeoJSON में मान्य है प्रारूप। – ghybs

संबंधित मुद्दे