注: 以下の翻訳の正確性は検証されていません。AIPを利用して英語版の原文から機械的に翻訳されたものです。
関連検索は、リンクまたは関数に基づく検索で、ユーザーが関連するオブジェクトを探索できます。Control Panel で関連検索の制限を設定できます。
ユーザーは、任意の地理空間オブジェクトから、そのオブジェクトにリンクされた任意の地理空間オブジェクトへの関連検索を実行できます。詳細については、リンクタイプを作成するを参照してください。
Map アプリケーションでは、地理空間オブジェクトが中間オブジェクト(地理空間オブジェクトでなくてもかまいません)を介して別の地理空間オブジェクトにリンクされている場合に、2段階の関連検索を実行できます。
Factory オブジェクトと Supplier オブジェクトは、Supply Contract オブジェクトを介して関連付けられている場合があります。関連検索を実行すると、Map は工場からサプライヤーへの弧を表示し、この弧は供給契約を表します。Customer オブジェクトは、Delivery イベントを介して Distribution Center オブジェクトにリンクされている場合があります。この場合、配送イベントは、弧に沿って移動する円として表示されます。円の位置は、イベントの開始時刻と終了時刻、および現在選択されているタイムスタンプに基づき、弧に沿って補間されます。
リンクをマージした関連検索で使用するオブジェクトを設定する方法は、次の2つです。
中間オブジェクトタイプを常にリンクマージするように指定するには、中間オブジェクトタイプの機能タブの関連検索セクションで、リンクは常にマージするをオンにします。これにより、オブジェクトタイプ自体は関連検索のリストに表示されなくなり、その推移的リンクが表示されます。

たとえば、中間オブジェクトタイプが Delivery で、両側のオブジェクトタイプが Distribution Center と Customer の場合、関連検索の起点として Distribution Center を選択すると、リストには Delivery ではなく Customer (via Delivery) が表示されます。以下の例を参照してください。

特定のリンクトラバーサルをリンクマージするように指定するには、中間オブジェクトタイプの機能タブの関連検索セクションで、マージする内向きリンクとマージする外向きリンクの両方を指定します。

たとえば、Supplier オブジェクトタイプから Delivery オブジェクトタイプを介して Distribution Center オブジェクトタイプへの関連検索を実行できるようにするには、Delivery <-> Supplier リンクをマージする内向きリンクとして、Delivery <-> Distribution Center リンクをマージする外向きリンクとして選択し、Delivery オブジェクトタイプを中間オブジェクトとして設定します。これにより、関連検索の起点として Supplier を選択すると、リストの選択肢に Distribution Centers (via Delivery) が表示されます。
リンクトラバーサルの両方向を関連検索のリストに表示する場合(たとえば、Suppliers に Distribution Centers (via Delivery) を表示し、かつ Distribution Centers に Suppliers (via Delivery) を表示する場合)、それらのリンクをマージする内向きリンクとマージする外向きリンクの両方として設定する必要があります。
Map 関連検索関数を記述することで、Map で使用する強力な Map 関連検索を作成できます。これにより、選択されたオブジェクトを受け取り、オントロジーをたどって、実行する特定の分析に関連する、または役立つすべてのオブジェクトを取得する TypeScript 関数を記述できます。
Map 関連検索関数は、次の要素を含めることができるデータ構造を返します。
objectRids:マップに追加されるオブジェクトです。edges:ソースオブジェクト、対象オブジェクト、および任意の中間オブジェクトを含むエッジです。ソースオブジェクトと対象オブジェクトがマップに追加され、それらの間に弧が描画されます。弧を選択すると、中間オブジェクトがリストに表示されます。measures:タイムラインに追加される時系列メジャーです。Map 関連検索関数は、TypeScript 関数リポジトリで開発します。詳細については、Functions のドキュメントを参照してください。
Map 関連検索関数では、戻り値の型を Promise<IMapSearchAroundResults> として宣言する必要があります。Map アプリケーションは、戻り値の型の名前と構造を使用して関連検索関数を見つけるため、戻り値の型は以下のとおり正確に宣言する必要があります。
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16export interface IMapSearchAroundResults { objectRids?: string[]; edges?: IMapSearchAroundEdge[]; measures?: IMapSearchAroundMeasure[]; } export interface IMapSearchAroundEdge { sourceObjectRid: string; targetObjectRid: string; intermediaryObjectRids?: string[]; } export interface IMapSearchAroundMeasure { objectRids: string[]; measureId: string; }
Map 関連検索関数には、オブジェクトパラメーターを必ず1個だけ含める必要があります。このパラメーターは、次のいずれかにできます。
Copied!1public exampleSearchAround(object: ExampleObjectType) { ...
Copied!1public exampleSearchAround(objects: ExampleObjectType[]) { ...
Copied!1public exampleSearchAround(objectSet: ObjectSet<ExampleObjectType>) { ...
Map 関連検索関数には、任意で、次のスカラー型の追加パラメーターを任意の個数含めることができます。string、boolean、Integer、Long、Float、Double、LocalDate、または Timestamp(詳細については、スカラー型を参照してください)。ユーザーが追加パラメーターを持つ関連検索関数を実行すると、パラメーターの値を入力するダイアログが表示されます。例:
Copied!1public exampleSearchAround(objectSet: ObjectSet<ExampleObjectType>, stringParameter: string, timestampParameter: Timestamp) { ...
all() と get() の代わりに allAsync() と getAsync() を使用し、await 文の使用をできるだけ少なくしてください。このサンプルコードには、オープンソースのサンプルデータに基づく3個の関連検索関数が含まれています。
airportsRelatedObjects:空港群に関連するさまざまなオブジェクトを返します。空港分析用のマップテンプレートで使用できます。nearbyAirports:地理空間検索を実行し、指定された距離内にあるほかの空港を見つけます。この関数は任意の距離パラメーターを受け取り、ユーザーは関数の実行時に距離を指定できます。routesBetweenAirports:空港群を受け取り、それらの空港間のみを結ぶすべての路線を返します。Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94import { Distance, Function, Integer, Filters } from "@foundry/functions-api"; import { ObjectSet, Objects, ExampleDataAirport } from "@foundry/ontology-api"; export interface IMapSearchAroundResults { objectRids?: string[]; edges?: IMapSearchAroundEdge[]; measures?: IMapSearchAroundMeasure[]; } export interface IMapSearchAroundEdge { sourceObjectRid: string; targetObjectRid: string; intermediaryObjectRids?: string[]; } export interface IMapSearchAroundMeasure { objectRids: string[]; measureId: string; } export class MapSearchAroundFunctions { /** * 空港に関連するオブジェクト(滑走路、路線)を返します。 */ @Function() public async airportsRelatedObjects(airportSet: ObjectSet<ExampleDataAirport>): Promise<IMapSearchAroundResults> { const relatedObjects = (await Promise.all([ airportSet.searchAroundExampleDataRunway().allAsync(), airportSet.searchAroundRoutes().allAsync(), ])).flat(); const objectRids = relatedObjects.map(o => o.rid!); return { objectRids, }; } /** * 選択した空港から指定した距離(キロメートル単位、デフォルトは50)以内にあるすべての空港を返します。 */ @Function() public async nearbyAirports(airport: ExampleDataAirport, distanceKm?: Integer): Promise<IMapSearchAroundResults> { const point = airport.airportLocation; const distance = Distance.ofKilometers(distanceKm ?? 50); if (point === undefined) { return {}; } const nearbyAirports = await Objects.search() .exampleDataAirport() .filter(airportFilter => airportFilter.airportLocation.withinDistanceOf(point, distance)) .allAsync(); const objectRids = nearbyAirports.map(o => o.rid!); return { objectRids, }; } /** * 出発地と到着地の両方が選択した空港である路線のみを返します。 */ @Function() public async routesBetweenAirports(airportSet: ObjectSet<ExampleDataAirport>): Promise<IMapSearchAroundResults> { const airports = await airportSet.allAsync(); const airportCodes = airports.map(airport => airport.airport); const airportsByCodes = new Map(Array.from(airports, a => [a.airport, a])); const routes = await Objects.search() .exampleDataRoute() .filter(route => Filters.and( route.origin.exactMatch(...airportCodes), route.dest.exactMatch(...airportCodes), )) .allAsync(); const edges = routes.map(route => ({ sourceObjectRid: airportsByCodes.get(route.origin!)!.rid!, targetObjectRid: airportsByCodes.get(route.dest!)!.rid!, intermediaryObjectRids: [route.rid!], })); return { edges }; } }