Wolfram言語

Knowledgebaseの拡張

有名な建物を徒歩で見学するルートを生成する

GeoNearestを使って,ボストンシティホールの周り半径1キロメートルの地域にある有名な建物を取り出すことができる.

In[1]:=
Click for copyable input
position = Entity["Building", "BostonCityHall::96t3t"]; radius = Quantity[1, "Kilometers"];
In[2]:=
Click for copyable input
nearMe = GeoNearest["Building", position, {All, radius}]
Out[2]=

組込みのアイコン実体を使って,地域の地図上に建物をプロットする.

完全なWolfram言語入力を表示する
In[3]:=
Click for copyable input
iconItemPairs = With[{icon = EntityValue[Entity["Icon", "Museum"], "Image"][[1]]}, MapThread[{#1, Graphics[{EdgeForm[Black], FaceForm[#2], icon}, "ImageSize" -> 25]} &, {nearMe, RandomColor[Length@nearMe]}] ]; legend = Column[ Row[Reverse@#] & /@ (MapAt[CommonName, #, 1] & /@ iconItemPairs)]; Row[{ GeoGraphics[{EdgeForm[Darker[Orange]], Orange, GeoDisk[position, radius], GeoMarker[position, "Color" -> Red], GeoMarker @@@ iconItemPairs}, ImageSize -> 400], legend }]
Out[3]=

TravelDirectionsを使って,これらの実体を徒歩で見学するルートを計算する.

In[4]:=
Click for copyable input
tourPlaces = Prepend[nearMe, position];
In[5]:=
Click for copyable input
{distance, tourPath} = FindShortestTour[GeoPosition /@ tourPlaces, 1, Length@tourPlaces]
Out[5]=
In[6]:=
Click for copyable input
travelDirectionsForPath = TravelDirections[tourPlaces[[tourPath]], TravelMethod -> "Walking"]
Out[6]=
完全なWolfram言語入力を表示する
In[7]:=
Click for copyable input
Row[{ GeoGraphics[{ Thickness[0.01], Darker@Red, GeoPath@travelDirectionsForPath, EdgeForm[Darker[Orange]], Orange, GeoDisk[position, radius], GeoMarker[position, "Color" -> Red], GeoMarker @@@ iconItemPairs }, ImageSize -> 400], legend }]
Out[7]=

以下は,ルートについての詳しい指示である.

In[8]:=
Click for copyable input
travelDirectionsForPath["ManeuverGrid"]
Out[8]=

関連する例

de en es fr ko pt-br ru zh