我有一个我试图调用的 COM 方法,其中有一个“对象”类型的参数,它必须是一个 2D 双安全数组,一个纬度/经度点的集合。如何在 JACOB 中创建 SafeArray 以通过 COM 接口发送?
我尝试将二维数组作为对象列表中的对象传递。该方法不返回错误,但我在 FalconView 中看不到预期的结果(多边形的渲染)。
double polyPoints[][] = new double[5][2];
polyPoints[0][0] = 75.3;
polyPoints[0][1] = 4.5;
polyPoints[1][0] = 3.8;
polyPoints[1][1] = 4.8;
polyPoints[2][0] = 2.3;
polyPoints[2][1] = 2.5;
polyPoints[3][0] = 5.3;
polyPoints[3][1] = 6.5;
polyPoints[4][0] = 0.3;
polyPoints[4][1] = -1.5;
// Can't recreate Variant or SafeArray from double[x][y] array;
Object[] polygonArgs = new Object[] {m_mainLayerHandle, polyPoints, 1};
Variant returnAddPolygon = Dispatch.invoke(mainLayerDispatch, "AddPolygon", Dispatch.Method, polygonArgs, new int[1]);
System.out.println("Polygon Handle: " + returnAddPolygon.getInt());
Object[] refreshArgs = new Object[] {m_mainLayerHandle};
Variant refreshVariant = Dispatch.invoke(mainLayerDispatch, "Refresh", Dispatch.Method, refreshArgs, new int[1]);
第二个arment文档:
lat_lon_array 双精度的二维 SAFEARRAY。第一个维度包含纬度值。第二个维度包含经度值