这个例子演示了如何创建一个圆,设置其属性,然后飞到它。这个例子使用了 ICreator701 (CreatePosition, CreateColor, CreateCircle, CreateMessage), INavigate701(FlyTo), IPosition701 (Copy, Pitch), IColor701, ITerrainRegularPolygon701 (Radius, Message), IFillStyle701 (Color) 和 ITerraExplorerMessage701 (ID) 接口。
private void CreateCircle() {
try {
UI.runOnRenderThread(new Runnable() {
@Override
public void run() {
// B. Create position for circle 1. 为圆创建一个坐标位置
// B1. Set position input parameters (San Fransico shore) 1.1 设置坐标位置的参数
double dXCoord = -122.49460;
double dYCoord = 37.78816;
double dAltitude = 100.0;
int eAltitudeTypeCode = 0;//AltitudeTypeCode.ATC_TERRAIN_RELATIVE;
double dYaw = 0.0;
double dPitch = 0.0;
double dRoll = 0.0;
double dDistance = 5000;
// B2. Create Position 1.2创建坐标位置
IPosition cPos = ISGWorld.getInstance().getCreator().CreatePosition(dXCoord, dYCoord, dAltitude, eAltitudeTypeCode, dYaw, dPitch, dRoll, dDistance);
// C. create FillColor for circle 2.为圆创建颜色
// {
// C1. Set fill color input params - RGB and Alpha 2.1设置填充颜色参数
int nRed = 0;
int nGreen = 255;
int nBlue = 0;
int nAlpha = 0x7F;
// 50% opacity
// C2. Create fill color 2.2创建填充颜色
IColor cFillColor = ISGWorld.getInstance().getCreator().CreateColor(nRed, nGreen, nBlue, nAlpha);
// }
// D. Create circle using created position and fill color (for line color use Abgr uint value)
// {
// D1. Set circle input params
Object nLineColor = 0xFFFF0000; // Abgr value - Solid blue
double dCircleRadius = 200; // in meters
// D2. Create circle v
ITerrainRegularPolygon cCircle = ISGWorld.getInstance().getCreator().CreateCircle(cPos, dCircleRadius, nLineColor, cFillColor, "", "Circle");
// } // // E. Get and change circle properties //
// { // E1. Get & Set circle radius
double dNewCircleRadius = 300;
double dCurrentCircleRadius = cCircle.getRadius();
// Get circle radius
cCircle.setRadius(dNewCircleRadius);
// Set new circle radius
// E2. Get fill style and change its properties
int nRGB_Red = 0xFF0000; // uing Rgb - Red color
double dAlpha = 0.2; // 80% transparent
IFillStyle cFillStyle = cCircle.getFillStyle();
cFillStyle.getColor().FromRGBColor(nRGB_Red);
cFillStyle.getColor().SetAlpha(dAlpha);
// } //
// F. Add Message to created circle //
// { // F1. Set message input parameters
int eMsgClient = 5; //MsgClient6.MC_POPUP;
String tMessage = "Hello Circle";
int eMsgType = 0; //MsgType.TYPE_TEXT;
boolean bIsBringToFront = true;
// F2. Create message and add to circle
ITerraExplorerMessage cMessage = ISGWorld.getInstance().getCreator().CreateMessage(eMsgClient, tMessage, eMsgType, bIsBringToFront);
cCircle.getMessage().setMessageID(cMessage.getID());
// }
// // G. FlyTo created circle //
// {
IPosition cFlyToPos = cPos.Copy();
cFlyToPos.setPitch(-89.0); // Set camera to look downward on circle
ISGWorld.getInstance().getNavigate().FlyTo(cFlyToPos);
// }
}
});
} catch (Exception e) {
Log.e("Tag", e.getMessage());
}
}
网友评论