diff --git a/Assets/Scenes/TreeWorld_02.unity b/Assets/Scenes/TreeWorld_02.unity index fa181c5f91158573de418db31b08185eef95e832..947462c0b74a8d09f8b84f136bd6518c631a7d4b 100644 --- a/Assets/Scenes/TreeWorld_02.unity +++ b/Assets/Scenes/TreeWorld_02.unity @@ -41104,6 +41104,11 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 2089306640899292912, guid: 4d99275c6663c25469ad3b65efcd4f5f, + type: 3} + propertyPath: m_AnchoredPosition.y + value: -0.00035664605 + objectReference: {fileID: 0} - target: {fileID: 2524590709578595355, guid: 4d99275c6663c25469ad3b65efcd4f5f, type: 3} propertyPath: m_AnchorMax.x diff --git a/Assets/Scripts/InteractionEngine/Fact.cs b/Assets/Scripts/InteractionEngine/Fact.cs index a5423a7e4e4e714e96f928141f7d43105b5d5424..a63e2dd3b75d94c06cc682f5a388239ab7cd0ffe 100644 --- a/Assets/Scripts/InteractionEngine/Fact.cs +++ b/Assets/Scripts/InteractionEngine/Fact.cs @@ -37,10 +37,11 @@ public static AddFactResponse sendAdd(string path, string body) //Put constructor parses stringbody to byteArray internally (goofy workaround) UnityWebRequest www = UnityWebRequest.Put(path, body); www.method = UnityWebRequest.kHttpVerbPOST; - // www.SetRequestHeader("Content-Type", "application/json"); - // www.timeout = 1; + www.SetRequestHeader("Content-Type", "application/json"); + www.timeout = 1; + //TODO: implement real asynchronous communication ... - AsyncOperation op = www.Send(); + AsyncOperation op = www.SendWebRequest(); while (!op.isDone) { } if (www.isNetworkError || www.isHttpError) { @@ -60,7 +61,7 @@ public class PointFact : Fact { public Vector3 Point; public Vector3 Normal; - public string ConceptName = "point"; + public PointFact(int i, Vector3 P, Vector3 N) { @@ -75,12 +76,11 @@ public PointFact(int i, Vector3 P, Vector3 N) new JSONManager.OMF(P.z) }; - JSONManager.MMTTerm tp = new JSONManager.OMA(new JSONManager.OMS(ConceptName), arguments); - JSONManager.MMTDeclaration mmtDecl = new JSONManager.MMTDeclaration() - { - label = "test", //TODO: rework label/id ? - tp = tp //JSONManager adds the id prefix - }; + //OMS constructor generates full URI + JSONManager.MMTTerm tp = new JSONManager.OMS("point"); + JSONManager.MMTTerm df = new JSONManager.OMA(new JSONManager.OMS("tuple"), arguments); + + JSONManager.MMTDeclaration mmtDecl = new JSONManager.MMTDeclaration("test", tp, df); string body = JSONManager.ToJson(mmtDecl); AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress+"/fact/add", body); diff --git a/Assets/Scripts/JSONManager.cs b/Assets/Scripts/JSONManager.cs index 6695d1f48068ae39c3e38a3d90d2b16e337a4101..e1e552bbfe4667e18fd0f579d3c728e1da1974e4 100644 --- a/Assets/Scripts/JSONManager.cs +++ b/Assets/Scripts/JSONManager.cs @@ -7,7 +7,15 @@ public static class JSONManager { - public static string URIPrefix = "http://mathhub.info/MitM/core/geometry?3DGeometry?"; + public static Dictionary<string, string> URIDictionary = new Dictionary<string, string> { + {"point", "http://mathhub.info/MitM/core/geometry?3DGeometry?point" }, + {"tuple", "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Tuple"}, + {"line", "http://mathhub.info/MitM/core/geometry?Geometry/Common?line_type" }, + {"distance", "http://mathhub.info/MitM/core/geometry?Geometry/Common?lineOf" } + }; + + + [JsonConverter(typeof(JsonSubtypes), "kind")] public class MMTTerm @@ -32,9 +40,12 @@ public class OMS : MMTTerm public string uri; public string kind = "OMS"; - public OMS(string uri) + public OMS(string uri, bool convertToURI = true) { - this.uri = URIPrefix + uri; + if (convertToURI) + this.uri = URIDictionary[uri]; + else + this.uri = uri; } } @@ -51,13 +62,13 @@ public OMF(float f) } } - + /* class DeclarationBody : MMTTerm { MMTTerm original; MMTTerm simplified; string kind = "O/S"; - } + }*/ public class MMTDeclaration @@ -65,6 +76,13 @@ public class MMTDeclaration public string label; public MMTTerm tp; public MMTTerm df; + + public MMTDeclaration(string label, MMTTerm tp, MMTTerm df) + { + this.label = label; + this.tp = tp; + this.df = df; + } } public static MMTDeclaration FromJson(string json)