public void TestAddLayer()
        {
            _utils           = new EarthNamedpipeAPIUtils();
            _utils.OnNotify += GetMessageFromArcGISEarth;
            Connect();
            List <LayerTestCase> lyrs = GetTestCases();

            AddLayers(lyrs);
        }
Example #2
0
        public void TestGetCameraJson()
        {
            if (_utils == null)
            {
                _utils = new EarthNamedpipeAPIUtils();
                string rlt = Connect().Result;
                Assert.AreEqual(EarthNamedpipeAPIUtils.cSuccess, rlt);
            }
            double lng;
            double lat;
            double alt;
            double heading;
            double pitch;
            int    wkid;
            string cameraJson = _utils.GetCamera();

            Assert.IsTrue(EarthNamedpipeAPIUtils.PaserCameraJson(cameraJson, out lng, out lat, out alt, out heading, out pitch, out wkid));
        }
Example #3
0
        public void TestSetCamera()
        {
            if (_utils == null)
            {
                _utils = new EarthNamedpipeAPIUtils();
                string rlt = Connect().Result;
                Assert.AreEqual(EarthNamedpipeAPIUtils.cSuccess, rlt);
            }

            double lng        = 100;
            double lat        = 10;
            double alt        = 5000000;
            double heading    = 0;
            double pitch      = 0;
            int    wkid       = 4326;
            string cameraJson = EarthNamedpipeAPIUtils.ConstructCameraJson(lng, lat, alt, heading, pitch, wkid);

            Assert.AreEqual(EarthNamedpipeAPIUtils.cSuccess, _utils.SetCamera(cameraJson));
        }
Example #4
0
 public MainWindowViewModel()
 {
     // Initialize variable and property.
     _utils                    = new EarthNamedpipeAPIUtils();
     InputString               = "";
     OutputString              = "";
     ConnectEarthCommand       = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.Connect));
     GetCameraCommand          = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.GetCamera));
     SetCameraCommand          = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.SetCamera));
     FlyToCommand              = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.FlyTo));
     AddLayerCommand           = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.AddLayer));
     ClearLayersCommand        = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.ClearLayers));
     GetSnapshotCommand        = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.GetSnapshot));
     GetLayerLoadStatusCommand = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.GetLayerLoadStatus));
     GetWorkspaceCommand       = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.GetWorkspace));
     ImportWorkspaceCommand    = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.ImportWorkspace));
     GetCameraCommand          = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.GetCamera));
     RemoveLayerCommand        = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.Removelayer));
     ClearInputBoxCommand      = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.ClearInputputBox));
     ClearOutputBoxCommand     = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.ClearOutputBox));
     HelpCommand               = new FunctionTypeCommand(e => ExecuteFuction(FunctionType.Help));
 }
        public async void ExecuteFuction(FunctionType functionType)
        {
            string inputString  = TextInfo;
            string outputString = "";

            if (_utils == null)
            {
                _utils           = new EarthNamedpipeAPIUtils();
                _utils.OnNotify += GetMessageFromArcGISEarth;
            }

            switch (functionType)
            {
            case FunctionType.AddLayer:
            {
                // inputString is Json description of layer
                outputString = _utils.AddLayer(inputString);
                break;
            }

            case FunctionType.ClearLayers:
            {
                // inputString is Json description of target
                outputString = _utils.ClearLayers(inputString);
                break;
            }

            case FunctionType.Connect:
            {
                // inputString is path of arcgis earth
                outputString = await _utils.Connect(inputString);

                break;
            }

            case FunctionType.FlyTo:
            {
                outputString = _utils.FlyTo(inputString);
                break;
            }

            case FunctionType.GetCamera:
            {
                outputString = _utils.GetCamera();
                break;
            }

            case FunctionType.GetSnapshot:
            {
                outputString = _utils.GetSnapshot(inputString);
                break;
            }

            case FunctionType.SetCamera:
            {
                outputString = _utils.SetCamera(inputString);
                break;
            }

            case FunctionType.Help:
            {
                //outputString = File.ReadAllText("C:\\Projects\\arcgisearth-namedpipe-client\\EarthAPITest\\EarthAPITest\\examples.txt");
                outputString = "Example of parameters:\r\n\r\nConnect (Note, it is not belong to API)\r\nC:\\Projects\\earth\\output\\earth_windesktop_release\\bin\\ArcGISEarth.exe\r\n\r\nSetCamera\r\n{  \r\n   \"mapPoint\":{  \r\n      \"x\":-97.283978521275117,\r\n      \"y\":48.422233665100165,\r\n      \"z\":11000000,\r\n      \"spatialReference\":{  \r\n         \"wkid\":4326\r\n      }\r\n   },\r\n   \"heading\":0.0,\r\n   \"pitch\":0.10000000000019954\r\n}\r\n\r\nFlyTo\r\n{  \r\n   \"camera\":{  \r\n      \"mapPoint\":{  \r\n         \"x\":-92,\r\n         \"y\":41,\r\n         \"z\":11000000,\r\n         \"spatialReference\":{  \r\n            \"wkid\":4326\r\n         }\r\n      },\r\n      \"heading\":0.0,\r\n      \"pitch\":0.099999999996554886\r\n   },\r\n   \"duration\":2\r\n}\r\n\r\nAddLayer\r\n{  \r\n   \"type\":\"MapService\",\r\n   \"URI\":\"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer\",\r\n   \"target\":\"OperationalLayers\"\r\n}\r\n\r\nClearLayers\r\n{  \r\n   \"target\":\"ElevationLayers\"\r\n}\r\n\r\nGetSnapshot (Note, the input parameters is Bitmap instead of string in API)\r\nD:/earth.jpg";
                break;
            }

            case FunctionType.ClearTextBox:
            {
                outputString = "";
                break;
            }

            case FunctionType.CloseConnect:
            {
                _utils.CloseConnect();
                break;
            }
            }

            TextInfo = outputString;
        }
Example #6
0
 private SyncToArcGISEarthButton()
 {
     _utils = new EarthNamedpipeAPIUtils();
 }