コード例 #1
0
    public IEnumerator updateLandMark(string landmarkId, int newlikes)
    {
        mapboxFeatureClass targetFeature = new mapboxFeatureClass();

        foreach (mapboxFeatureClass i in RetrievedFeatureList.features)
        {
            if (i.properties.landmarkID == landmarkId)
            {
                Debug.Log("Found Feature Match: " + landmarkId);
                targetFeature = i;
                Debug.Log(targetFeature.properties.name.ToString());
            }
        }
        targetFeature.properties.likes = newlikes;
        string          updatedJson     = JsonUtility.ToJson(targetFeature);
        string          endpoint_update = "https://api.mapbox.com/datasets/v1/tankbusta/" + dataset_id + "/features/" + targetFeature.properties.landmarkID + "?access_token=" + secret_token;
        UnityWebRequest www             = UnityWebRequest.Put(endpoint_update, updatedJson);

        www.SetRequestHeader("Content-Type", "application/json");
        yield return(www.SendWebRequest());

        responseCode = www.responseCode.ToString();

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log("Error: " + www.error);
        }
        else
        {
            Debug.Log("Updated Landmark!");
            Debug.Log("Passed " + www.downloadHandler.text);
        }
    }
コード例 #2
0
    public void SpawnExistingLandMarkIntoScene(string feature_id, mapboxFeatureClass feature)
    {
        Vector2d existingLandMarkLocation;

        existingLandMarkLocation.y = feature.geometry.coordinates[0];
        existingLandMarkLocation.x = feature.geometry.coordinates[1];
        Vector3 existingLandMarkUnityLocation = locationProviderFactoryLink.mapManager.GeoToWorldPosition(existingLandMarkLocation);

        //FIND A BETTER WAY TO DO THIS #TODO
        existingLandMarkUnityLocation.y = -1;

        GameObject existingLandMark = GameObject.Instantiate(landMarkPrefab, existingLandMarkUnityLocation, landMarkPrefab.transform.rotation);

        existingLandMark.name = "Landmark_" + feature_id.ToString();
        existingLandMark.transform.localScale = landmarkScale;

        //Preload physical look values from the data on the cloud
        existingLandMark.GetComponent <ARLandMarkInternalController>().landmarkLogo          = feature.properties.logoShape;
        existingLandMark.GetComponent <ARLandMarkInternalController>().stringlandmarkText    = feature.properties.name;
        existingLandMark.GetComponent <ARLandMarkInternalController>().stringlandmarkCreator = feature.properties.creator;
        existingLandMark.GetComponent <ARLandMarkInternalController>().landMarkID            = feature.properties.landmarkID;
        existingLandMark.GetComponent <ARLandMarkInternalController>().stringlandMarkLikes   = feature.properties.likes.ToString();

        //Add to LiveList
        LiveLandMarks.Add(existingLandMark);
    }
コード例 #3
0
    public IEnumerator createLandmark(Vector2d landmarkLocation, string LandMarkName, string feature_id, float landmarkHeight, string landmarkLogoShape, string creatorName)
    {
        //Prepare Dynamic Placeholders
        mapboxFeatureClass testLandMark       = new mapboxFeatureClass();
        Properties         featureProperties  = new Properties();
        Geometry           featureGeometry    = new Geometry();
        List <double>      featurecoordinates = new List <double>();

        testLandMark.properties           = featureProperties;
        testLandMark.geometry             = featureGeometry;
        testLandMark.geometry.coordinates = featurecoordinates;
        var userFocusVector2D = locationProviderFactoryLink.mapManager.WorldToGeoPosition(userFocusSquare.focusSquareRayCastHitVector);

        //Fill in the landmark Data
        testLandMark.id              = feature_id;
        testLandMark.type            = "Feature";
        testLandMark.properties.name = LandMarkName;
        testLandMark.geometry.coordinates.Add(landmarkLocation.y);
        testLandMark.geometry.coordinates.Add(landmarkLocation.x);
        testLandMark.geometry.type         = "Point";
        testLandMark.properties.creator    = creatorName;
        testLandMark.properties.likes      = 0;
        testLandMark.properties.landmarkID = feature_id;
        testLandMark.properties.logoShape  = landmarkLogoShape;

        //Add the to spawn lists
        dynamicFeatureList.Add(testLandMark);

        //Final JSON Conversion
        jsonOutput = JsonUtility.ToJson(testLandMark);

        //Start Sending the landmark to MBApi
        string          endpoint_create = "https://api.mapbox.com/datasets/v1/tankbusta/" + dataset_id + "/features/" + feature_id + "/?access_token=" + secret_token;
        UnityWebRequest www             = UnityWebRequest.Put(endpoint_create, jsonOutput);

        www.SetRequestHeader("Content-Type", "application/json");
        yield return(www.SendWebRequest());

        responseCode = www.responseCode.ToString();

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log("Error: " + www.error);
        }
        else
        {
            Debug.Log("Passed " + www.downloadHandler.text);
        }
    }
コード例 #4
0
    public float landMarkDistance(mapboxFeatureClass inputFeature, Vector3 LookAtRaycast)
    {
        //This function calculates the distance between the user's focus square and a particular feature
        Vector3  featureVector3;
        Vector2d featureVector2d;

        //Need to check the latlon or lonlat here
        //Appears That X is Lat and Y is Lon
        //JSON 0 is Lon and 1 is Lat
        //Still to be confirmed
        featureVector2d.x = inputFeature.geometry.coordinates[1];
        featureVector2d.y = inputFeature.geometry.coordinates[0];
        featureVector3    = locationProviderFactoryLink.mapManager.GeoToWorldPosition(featureVector2d);
        return(Vector3.Distance(LookAtRaycast, featureVector3));
    }
コード例 #5
0
    public IEnumerator createLandmark()
    {
        double x = 51.186553490730;
        double y = 21.497919311020;

        string feature_id = "d470b6133258df834ed36fc0c3ec0";

        mapboxFeatureClass testLandMark = new mapboxFeatureClass();

        Properties    featureProperties  = new Properties();
        Geometry      featureGeometry    = new Geometry();
        List <double> featurecoordinates = new List <double>();

        testLandMark.properties           = featureProperties;
        testLandMark.geometry             = featureGeometry;
        testLandMark.geometry.coordinates = featurecoordinates;


        testLandMark.id              = feature_id;
        testLandMark.type            = "Feature";
        testLandMark.properties.name = "ThePlace";
        testLandMark.geometry.coordinates.Add(x);
        testLandMark.geometry.coordinates.Add(y);
        testLandMark.geometry.type = "Point";


        //This worked
        //string workingoutput = "{\"type\":\"Feature\",\"properties\":{\"name\":\"Null Island\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[-2.3626667261123657,53.45663959042344]}}";
        jsonOutput = JsonUtility.ToJson(testLandMark);

        //string endpoint_create = "https://api.mapbox.com/datasets/v1/tankbusta/cka0vudxx13p72smuavafd1um/features/236d470b6133258df834ed36fc0c3ec0?access_token=sk.eyJ1IjoidGFua2J1c3RhIiwiYSI6ImNrYWQ3MjN6ODFqMWMzNHM5NzM3bm40ajgifQ.WEZKnrork6sshSBo1aPcjA";
        string          endpoint_create = "https://api.mapbox.com/datasets/v1/tankbusta/cka0vudxx13p72smuavafd1um/features/" + feature_id + "/?access_token=sk.eyJ1IjoidGFua2J1c3RhIiwiYSI6ImNrYWQ3MjN6ODFqMWMzNHM5NzM3bm40ajgifQ.WEZKnrork6sshSBo1aPcjA";
        UnityWebRequest www             = UnityWebRequest.Put(endpoint_create, jsonOutput);

        www.SetRequestHeader("Content-Type", "application/json");
        yield return(www.SendWebRequest());

        responseCode = www.responseCode.ToString();

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log("Error: " + www.error);
        }
        else
        {
            Debug.Log("Passed " + www.downloadHandler.text);
        }
    }