Exemple #1
0
    IEnumerator SaveMap()
    {
        bool useLocation = Input.location.status == LocationServiceStatus.Running;

        mapping = false;
        LocationInfo locationInfo = Input.location.lastData;

        MapnameInputPopUp.SetActive(true);
        statusText.text = "Wait for map name input....";

        yield return(new WaitUntil(() => haveMapName == true));

        statusText.text = "Saving...";
        LibPlacenote.Instance.SaveMap(
            (mapId) => {
            LibPlacenote.Instance.StopSession();
            FeaturesVisualizer.clearPointcloud();

            mSaveMapId = mapId;
            mInitButtonPanel.SetActive(true);
            mMappingButtonPanel.SetActive(false);
            mExitButton.SetActive(false);

            LibPlacenote.MapMetadataSettable metadata = new LibPlacenote.MapMetadataSettable();

            metadata.name = inputManager.MapName;                     // set name here

            statusText.text = "Saved Map Name: " + metadata.name;

            JObject userdata  = new JObject();
            metadata.userdata = userdata;

            JObject shapeList = shapeManager.Shapes2JSON();

            userdata["shapeList"] = shapeList;
            //can add userdata of trigger later
            shapeManager.ClearShapes();

            if (useLocation)
            {
                metadata.location           = new LibPlacenote.MapLocation();
                metadata.location.latitude  = locationInfo.latitude;
                metadata.location.longitude = locationInfo.longitude;
                metadata.location.altitude  = locationInfo.altitude;
            }
            LibPlacenote.Instance.SetMetadata(mapId, metadata, (success) => {
                if (success)
                {
                    Debug.Log("Meta data successfully saved");
                }
                else
                {
                    Debug.Log("Meta data failed to save");
                }
            });
            mCurrMapDetails = metadata;
        },
            (completed, faulted, percentage) => {
            if (completed)
            {
                statusText.text = "Upload Complete:" + mCurrMapDetails.name;
                OnExitClick();
            }
            else if (faulted)
            {
                statusText.text = "Upload of Map Named: " + mCurrMapDetails.name + "faulted";
            }
            else
            {
                statusText.text = "Uploading Map Named: " + mCurrMapDetails.name + "(" + percentage.ToString("F2") + "/1.0)";
            }
        }
            );
    }