2017-05-31 11 views
1

http://stackoverflow.com/questions/18766430/how-can-i-do-d3-svg-arc-within-a-given-map-projectionの後に、ある方位角、天頂角、および所定の開き角で円弧を表示するように少し修正したバージョンがあります。これまでの私の努力は以下の通りです。D3円弧は必要に応じて表示されません

(Az、Ze)0,90と0,45で円弧を作成した場合、円弧は予想されるところです。しかし、Ze = 45度でAz = 45度ごとに円弧を欲しければ、円弧は周回するのではなく、投影から外れてしまう傾向があります。

ここで何が起こっているのでしょうか? Jsfiddleは:http://jsfiddle.net/3p9c4kzo/1/

var width = 600, 
height = 600; 

var flippedStereographic = function(lam, phi) { 
      var cosl = Math.cos(lam), 
      cosp = Math.cos(phi), 
      k = 1/(1 + cosl * cosp); 
      return [ k * cosp * Math.sin(lam), -k * Math.sin(phi) ]; 
}; 

var projection = d3.geo 
.projection(flippedStereographic) 
.rotate([0, -90]) 
.scale(180) 
.translate([width/2, height/2]) 
.clipAngle(90) 
.precision(.1); 

var path = d3.geo.path() 
.projection(projection); 

var graticule = d3.geo.graticule(); 

var svg = d3.select("body").append("svg") 
.attr("width", width) 
.attr("height", height); 

svg.append("defs").append("path") 
.datum({ 
type: "Sphere" 
}) 
.attr("id", "sphere") 
.attr("d", path); 

svg.append("use") 
.attr("class", "stroke") 
.attr("xlink:href", "#sphere"); 

svg.append("use") 
.attr("class", "fill") 
.attr("xlink:href", "#sphere"); 

svg.append("path") 
.datum(graticule) 
.attr("class", "graticule") 
.attr("d", path); 

function geoArc(center, radius, startAngle, endAngle, steps) { 
coordinates = [] 
for (var i = 0; i <= steps; i++) { 
    var curAngle = (startAngle + (endAngle - startAngle) * i/steps); 
    coordinates[i] = d3.geo.rotation(center)(d3.geo.rotation([0, 0, 
curAngle])([radius, 0])) 
} 
return { 
    type: "LineString", 
    coordinates: coordinates 
}; 
} 

svg.append("path") 
.datum(geoArc([0,90], 30, 0, 360, 40)) 
.classed("circle", true) 
.attr("d", path); 

svg.append("path") 
    .datum(geoArc([0,45], 30, 0, 360, 40)) 
.classed("circle", true) 
.attr("d", path); 

svg.append("path") 
    .datum(geoArc([45,45], 30, 0, 360, 40)) 
.classed("circle", true) 
.attr("d", path); 

svg.append("path") 
    .datum(geoArc([90,45], 30, 0, 360, 40)) 
.classed("circle", true) 
.attr("d", path); 
+0

興味深いことに、Iは、方位角= 0がもはや指しているにもかかわらず、circle->楕円の正しい表現を見ません真北。私は、上に提示されたアルゴリズムは、正書法固有のものだと思います。 – smader

答えて

0

コードが両方の正投影とステレオ投影に適していると思われます。正書法は歪曲し、コンフォーマルではありませんが、Stereographicはコンフォーマルで歪みはありません(それほど多くはありません)。私はちょうど正投影に投影を変更する場合

は正投影 https://au.mathworks.com/help/map/ortho.html

ステレオグラフィックは https://au.mathworks.com/help/map/stereo.html

+0

あなたの質問を編集するか、実際に問題がなかったことを説明する回答を追加することを意味しましたか? –

+0

2番目のオプション:)私は答えがそれを閉じるだろうと思った。 – smader

関連する問題