public void DeepCloneTest()//深拷贝测试 { DataTable table = new DataTable(); table.Columns.Add("column1"); table.Columns.Add("column2"); DataRow row = table.NewRow(); row[0] = 111; row[1] = 222; table.Rows.Add(row); Point3D testPoint1 = new Point3D { X = 0, Y = 0, Z = 0 }; FeatureObject featureObject = new FeatureObject() { Coordinates = new List <Point3D>() { testPoint1 }, LayerName = "test1", FeatureAttribute = row }; var obj = featureObject.Clone(); Assert.AreNotEqual(featureObject.GetHashCode(), obj.GetHashCode()); var result = featureObject.Equals(obj); Assert.AreEqual(result, true); }
public void EqualsTest5()//完全相同测试 { DataTable table = new DataTable(); table.Columns.Add("column1"); table.Columns.Add("column2"); DataRow row = table.NewRow(); row[0] = 111; row[1] = 222; table.Rows.Add(row); Point3D testPoint1 = new Point3D { X = 0, Y = 0, Z = 0 }; FeatureObject featureObject = new FeatureObject() { Coordinates = new List <Point3D>() { testPoint1 }, LayerName = "test1", FeatureAttribute = row }; FeatureObject featureObjectCompare = new FeatureObject() { Coordinates = new List <Point3D>() { testPoint1 }, LayerName = "test1", FeatureAttribute = row }; var result = featureObject.Equals(featureObjectCompare); Assert.AreEqual(result, true); }
public void GetHashCodeTest() { DataTable table = new DataTable(); table.Columns.Add("column1"); table.Columns.Add("column2"); DataRow row = table.NewRow(); row[0] = 111; row[1] = 222; table.Rows.Add(row); Point3D testPoint1 = new Point3D { X = 0, Y = 0, Z = 0 }; List <Point3D> list = new List <Point3D>() { testPoint1 }; FeatureObject featureObject = new FeatureObject() { Coordinates = list, LayerName = "test1", FeatureAttribute = row }; FeatureObject featureObject2 = new FeatureObject() { Coordinates = list, LayerName = "test1", FeatureAttribute = row }; Assert.AreEqual(featureObject.GetHashCode(), featureObject2.GetHashCode()); var obj = featureObject.Clone(); Assert.AreNotEqual(featureObject.GetHashCode(), obj.GetHashCode()); }
public void EqualsTest2()//LayerName不同,FeatureAttribute为空等测试 { Point3D testPoint1 = new Point3D { X = 0, Y = 0, Z = 0 }; Point3D testPoint2 = new Point3D { X = 0, Y = 0, Z = 0 }; FeatureObject featureObject = new FeatureObject() { Coordinates = new List <Point3D>() { testPoint1 }, LayerName = "test1", FeatureAttribute = null }; FeatureObject featureObjectCompare = new FeatureObject() { Coordinates = new List <Point3D>() { testPoint2 }, LayerName = null, FeatureAttribute = null }; var result = featureObject.Equals(featureObjectCompare); Assert.AreEqual(result, false); }
private IEnumerator GetFeatureObject(FeatureObject obj, int idx, int collCount) { // get bikeId string bikeId = ""; if (obj.properties.TryGetValue("bikeId", out bikeId)) { // Debug.Log("FeatureObject: " + bikeId); } // get fromStationId string fromStationId = ""; if (obj.properties.TryGetValue("fromStationId", out fromStationId)) { // Debug.Log("FeatureObject: " + fromStationId); } // get toStationId string toStationId = ""; if (obj.properties.TryGetValue("toStationId", out toStationId)) { // Debug.Log("FeatureObject: " + toStationId); } // get fromTime string fromTime = ""; if (obj.properties.TryGetValue("fromTime", out fromTime)) { // Debug.Log("FeatureObject: " + System.DateTime.Parse(fromTime)); } // get toTime string toTime = ""; if (obj.properties.TryGetValue("toTime", out toTime)) { // Debug.Log("FeatureObject: " + System.DateTime.Parse(toTime)); } // get coordinates GeoJSON.LineStringGeometryObject geomLines = (LineStringGeometryObject)obj.geometry; StartCoroutine(CreateRouteGameObject(geomLines.coordinates, bikeId, System.DateTime.Parse(fromTime), System.DateTime.Parse(toTime), idx)); float fill = idx / (float)collCount; loading_bar.localScale = new Vector3(fill, 1f, 1f); //Debug.Log("Fill amount " + fill.ToString() + " idx " + idx + " / collCount " + collCount); yield return(null); }
public static FeatureObject ParseFeature(JsonObject featureJson) { FeatureObject result = null; //处理属性 object[] attrJson; bool found = false; found = featureJson.TryGetArray("attribute", out attrJson); if (!found && attrJson == null) { throw new ArgumentNullException("features>attribute can not parse to jsonobject"); } //处理图形 JsonObject geoJson; found = featureJson.TryGetJsonObject("geometry", out geoJson); if (!found && geoJson == null) { throw new ArgumentNullException("features>geometry can not parse to jsonobject"); } //解析条件 JsonObject filterJson; found = featureJson.TryGetJsonObject("filterWhere", out filterJson); if (!found && filterJson == null) { throw new ArgumentNullException("features>filterWhere can not parse to jsonobject"); } result = new FeatureObject(); result.filterWhere = ParseFilterWhere(filterJson); List <AttributeJSObject> attrs = new List <AttributeJSObject>(); foreach (object o in attrJson) { JsonObject jo = o as JsonObject; if (jo != null) { AttributeJSObject attjsObj = ParseAttribute(jo); attrs.Add(attjsObj); } } result.attributes = attrs; //解析图形数据,包括点线面 result.geometry = ParseGeometry(geoJson); return(result); }
public override object Predict(FeatureObject feature, double[] weightArray) { double result = 0; double[] features = feature.GetFeature(); //multiply feature by weight for (int i = 0; i < weightArray.Length; i++) { result += features[i] * weightArray[i]; } return(1 / (1 + Math.Exp(-result))); }
public void ImplementedInterfacesAreEnumerated() { var env = new Dictionary <string, object> { { "owin.RequestMethod", "POST" } }; var features = new FeatureObject(new OwinFeatureCollection(env)); var entries = features.ToArray(); var keys = features.Keys.ToArray(); var values = features.Values.ToArray(); Assert.Contains(typeof(IHttpRequestFeature), keys); Assert.Contains(typeof(IHttpResponseFeature), keys); }
public void OwinHttpEnvironmentCanBeCreated() { var env = new Dictionary <string, object> { { "owin.RequestMethod", "POST" }, { "owin.RequestPath", "/path" }, { "owin.RequestPathBase", "/pathBase" }, { "owin.RequestQueryString", "name=value" }, }; var features = new FeatureObject(new OwinFeatureCollection(env)); var requestFeature = Get <IHttpRequestFeature>(features); Assert.Equal(requestFeature.Method, "POST"); Assert.Equal(requestFeature.Path, "/path"); Assert.Equal(requestFeature.PathBase, "/pathBase"); Assert.Equal(requestFeature.QueryString, "?name=value"); }
/// <summary> /// MethodOfMaximumLikehood /// </summary> /// <param name="weightArray"></param> /// <param name="dataSet"></param> /// <returns></returns> internal override object GetTotalCost(double[] weightArray, DataSetObject dataSet) { double totalCost = 0; foreach (var item in dataSet.DataSet) { FeatureObject tmpFeature = item.Value.Feature; double predictResult = (double)Predict(tmpFeature, weightArray); double label = (double)item.Value.Label.Label; totalCost += label * Math.Log10(predictResult) - (1 - label) * Math.Log(1 - predictResult); } totalCost /= dataSet.RowCount; return(totalCost); }
/// <summary> /// 几何图形解析 /// </summary> /// <param name="featruesJson"></param> /// <returns></returns> public static List <FeatureObject> ParseFeatures(object[] featruesJson) { List <FeatureObject> result = new List <FeatureObject>(); foreach (object o in featruesJson) { JsonObject jo = o as JsonObject; if (jo != null) { FeatureObject fo = ParseFeature(jo); if (fo != null) { result.Add(fo); } } } return(result); }
public override void CopyFrom(DomainObject <long> T) { var velotype = T as VeloObject; if (velotype == null) { return; } VeloLength = velotype.VeloLength; VeloWidth = velotype.VeloWidth; VeloSection = velotype.VeloSection; DataSet = velotype.DataSet; DataCheck = velotype.DataCheck; VeloView = velotype.VeloView; VeloType = velotype.VeloType; VeloObjectStatus = velotype.VeloObjectStatus; FeatureObject = velotype.FeatureObject; Angle = velotype.Angle; }
public void EqualsTest() { FeatureObject featureObject = new FeatureObject() { Coordinates = null }; FeatureObject featureObjectCompare = new FeatureObject() { Coordinates = null }; //类型不匹配测试 var result1 = featureObject.Equals(""); Assert.AreEqual(result1, false); //Coordinates相等且为null测试 var result2 = featureObject.Equals(featureObjectCompare); Assert.AreEqual(result2, true); }
public void OwinHttpEnvironmentCanBeModified() { var env = new Dictionary <string, object> { { "owin.RequestMethod", "POST" }, { "owin.RequestPath", "/path" }, { "owin.RequestPathBase", "/pathBase" }, { "owin.RequestQueryString", "name=value" }, }; var features = new FeatureObject(new OwinFeatureCollection(env)); var requestFeature = Get <IHttpRequestFeature>(features); requestFeature.Method = "GET"; requestFeature.Path = "/path2"; requestFeature.PathBase = "/pathBase2"; requestFeature.QueryString = "?name=value2"; Assert.Equal("GET", Get <string>(env, "owin.RequestMethod")); Assert.Equal("/path2", Get <string>(env, "owin.RequestPath")); Assert.Equal("/pathBase2", Get <string>(env, "owin.RequestPathBase")); Assert.Equal("name=value2", Get <string>(env, "owin.RequestQueryString")); }
private IEnumerator GetFeatureObject(FeatureObject obj) { // get id string id = ""; if (obj.properties.TryGetValue("STRSCHL", out id)) { //Debug.Log("FeatureObject: " + id); } // get coverage string coverageStr = ""; float coverageFloat = 0f; if (obj.properties.TryGetValue("ABDECKUNG", out coverageStr)) { coverageFloat = float.Parse(coverageStr, CultureInfo.InvariantCulture.NumberFormat); if (coverageFloat > 0.0f) { //Debug.Log("FeatureObject: " + coverageFloat); } } // get coordinates GeoJSON.MultiLineStringGeometryObject geomLines = (MultiLineStringGeometryObject)obj.geometry; if (geomLines.coordinates.Count > 0 && id != "" && coverageStr != "") { foreach (List <PositionObject> section in geomLines.coordinates) { yield return(StartCoroutine(CreateRouteGameObject(section, id, coverageFloat))); } } yield return(null); }
private void GetFeatureObject(FeatureObject obj) { // get name string propName = ""; if (obj.properties.TryGetValue("name", out propName)) { // Debug.Log("FeatureObject: " + propName); } // get id string id = ""; if (obj.properties.TryGetValue("id", out id)) { // Debug.Log("FeatureObject: " + id); } // get coordinates GeoJSON.SingleGeometryObject geomCoords = (SingleGeometryObject)obj.geometry; Vector3 stationPosition = Quaternion.AngleAxis(geomCoords.coordinates.longitude, -Vector3.up) * Quaternion.AngleAxis(-geomCoords.coordinates.latitude, -Vector3.right) * new Vector3(0, 0, -6371.375f); //Vector3 stationPosition = new Vector3(geomLon.coordinates.longitude, geomLon.coordinates.latitude, -0.0125f); // create object at identity position GameObject stationObject = Instantiate <GameObject>(prefabToGenerate, Vector3.zero, Quaternion.Euler(new Vector3(0, 0, 0))); // add to worldRoot and position stationObject.transform.parent = worldRoot.transform; // reset position stationObject.transform.localPosition = Vector3.zero; stationObject.transform.localScale = Vector3.Scale(Vector3.one, new Vector3(0.1f, 0.1f, 0.1f)); // Debug.Log(stationObject.transform.localPosition); // set scaled position stationObject.transform.localPosition = stationPosition; stationObject.transform.LookAt(2 * stationObject.transform.position - worldRoot.transform.position); // Debug.Log(stationObject.transform.localPosition); }
internal object Predict(FeatureObject feature) { return(_predictor.Predict(feature, WeightArray)); }
internal object Predict(FeatureObject feature) { return(_hypothesis.Predict(feature)); }
public static Boolean HasAccess(Upsilab.Data.Model.User user, FeatureObject featureObject, OperationType operation, Boolean requiresLABLicense = false, Boolean requiresReportLicense = false) { //Rule #1: User must be active if (!user.IsActive) return false; if (featureObject == null) return false; //Rule #2: User Profile something var temp = FeatureAccessBL.GetAllFeatureAccess().Where(featureAccess => featureAccess.idUserProfile == user.idUserProfile) .Where(featureAccess => featureAccess.idFeatureObject == featureObject.idFeatureObject).FirstOrDefault(); if (temp == null) return false; else { switch (operation) { case OperationType.Create: if (!temp.CanCreate) return false; break; case OperationType.Retrieve: if (!temp.CanRetrieve) return false; break; case OperationType.Update: if (!temp.CanUpdate) return false; break; case OperationType.Delete: if (!temp.CanDelete) return false; break; default: return false; } } //Rule #3: Expiration of Firm/Institution Boolean licenseResult = true; if (requiresLABLicense) licenseResult = FirmInstitutionBL.DoesFirmInstitutionHaveValidLABLicense(FirmInstitutionBL.GetFirmInstitutionByUser(user)); if (requiresReportLicense) licenseResult = FirmInstitutionBL.DoesFirmInstitutionHaveValidReportLicense(FirmInstitutionBL.GetFirmInstitutionByUser(user)); if (requiresLABLicense && requiresReportLicense) licenseResult = FirmInstitutionBL.DoesFirmInstitutionHaveAnyValidLicense(FirmInstitutionBL.GetFirmInstitutionByUser(user).idFirmInstitution); if (!licenseResult) return false; //Rule #4: Firm Institution Attribute Value Complete //Pending //if he passes everything, return true return true; }
public override void Load() { if (Data == null) { return; } // Load the geoJSON file FeatureCollection collection = GeoJSONObject.Deserialize(Data.text); // Create a list of lists that we will be populating with our fortified shape data List <List <string> > geoData = new List <List <string> >(); for (int i = 0; i < 5; i++) { geoData.Add(new List <string>()); } // Create another dictionary of lists that will contain the properties that are encoded within the geoJSON file Dictionary <string, List <string> > propertyData = new Dictionary <string, List <string> >(); foreach (string property in collection.features[0].properties.Keys) { propertyData[property] = new List <string>(); } for (int i = 0; i < collection.features.Count; i++) { FeatureObject feature = collection.features[i]; int order = 0; if (feature.geometry.type == "Polygon") { PolygonGeometryObject geometry = (PolygonGeometryObject)feature.geometry; for (int j = 0; j < geometry.coordinates.Count; j++) { List <PositionObject> positionObjects = geometry.coordinates[j]; for (int k = 0; k < positionObjects.Count - 1; k++) // Ignore last coordinate { PositionObject point = positionObjects[k]; geoData[0].Add(point.longitude.ToString()); geoData[1].Add(point.latitude.ToString()); geoData[2].Add(order.ToString()); geoData[3].Add(i.ToString()); geoData[4].Add(j.ToString()); foreach (var property in feature.properties) { propertyData[property.Key].Add(property.Value); } order++; } } } else if (feature.geometry.type == "MultiPolygon") { MultiPolygonGeometryObject geometry = (MultiPolygonGeometryObject)feature.geometry; for (int j = 0; j < geometry.coordinates.Count; j++) { List <List <PositionObject> > polygon = geometry.coordinates[j]; for (int k = 0; k < polygon.Count; k++) { List <PositionObject> positionObjects = polygon[k]; for (int l = 0; l < positionObjects.Count - 1; l++) // Ignore last coordinate { PositionObject point = positionObjects[l]; geoData[0].Add(point.longitude.ToString()); geoData[1].Add(point.latitude.ToString()); geoData[2].Add(order.ToString()); geoData[3].Add(i.ToString()); geoData[4].Add(j.ToString()); foreach (var property in feature.properties) { propertyData[property.Key].Add(property.Value); } order++; } } } } } // Populate data structures originalData = new List <string[]>(); attributes = new List <DataAttribute>(); foreach (var list in geoData) { originalData.Add(list.ToArray()); } attributes.Add(new DataAttribute("Longitude", IATKDataType.Numeric, originalData[0].ToArray())); attributes.Add(new DataAttribute("Latitude", IATKDataType.Numeric, originalData[1].ToArray())); attributes.Add(new DataAttribute("Order", IATKDataType.Numeric, originalData[2].ToArray())); attributes.Add(new DataAttribute("Group", IATKDataType.Factor, originalData[3].ToArray())); attributes.Add(new DataAttribute("Piece", IATKDataType.Factor, originalData[4].ToArray())); foreach (var property in propertyData) { string[] array = property.Value.ToArray(); IATKDataType dataType = DataTypesExtension.InferFromString(array[0]); originalData.Add(array); attributes.Add(new DataAttribute(property.Key, dataType, array)); } DataCount = attributes[0].Length; }
//protected ICostFunction _costFunction; abstract public object Predict(FeatureObject feature, double[] weightArray);