public void UpdateAnnotedObject(AnnotatedObject obj) { if (GameObject.Find("Holograms/" + name) != null) { Debug.Log("GameObjectManager"); } }
private static AnnotatedObject <Geometry>[] getGeomsFromShpFile(string fileName) { List <AnnotatedObject <Geometry> > output = new List <AnnotatedObject <Geometry> >(); using (var reader = new ShapefileDataReader(fileName, GeometryFactory.Default)) { while (reader.Read()) { DbaseFileHeader h = reader.DbaseHeader; int fieldCount = h.NumFields; var geom = reader.Geometry; geom.Normalize(); var obj = new AnnotatedObject <Geometry>(geom); for (int i = 1; i <= fieldCount; i++) { try { obj.Data[h.Fields[i - 1].Name] = reader.GetValue(i); } catch { } } output.Add(obj); } } return(output.ToArray()); }
public List <AnnotatedObject <ComplexPolygon> > GetComplexPolysFromFile() { if (m_complexPolygons != null) { return(m_complexPolygons); } List <AnnotatedObject <ComplexPolygon> > output = new List <AnnotatedObject <ComplexPolygon> >(); List <AnnotatedObject <Geometry> > geoms = GetGeomsFromFile(); foreach (AnnotatedObject <Geometry> geom in geoms) { AnnotatedObject <ComplexPolygon> poly = new AnnotatedObject <ComplexPolygon>(GetComplexPolygonFromGeometry(geom.Object)); foreach (KeyValuePair <string, object> kvp in geom.Data) { poly.Data.Add(kvp.Key, kvp.Value); } poly.Object.ComputeArea(); output.Add(poly); } output.Sort(m_comparer); return(m_complexPolygons = output); }
public int Compare(AnnotatedObject <ComplexPolygon> p1, AnnotatedObject <ComplexPolygon> p2) { if (p1.Object.Area == p2.Object.Area) { return(0); } if (p1.Object.Area < p2.Object.Area) { return(-1); } return(1); }
private static AnnotatedObject <Dictionary <object, object> > buildSubDictionaries( List <KeyValuePair <string, object> > parentCategories, Dictionary <string, HashSet <object> > subCategories, List <AggregatedData <T> > aggregatedData) { AnnotatedObject <Dictionary <object, object> > output = new AnnotatedObject <Dictionary <object, object> >(new Dictionary <object, object>()); var dictionary = output.Object; KeyValuePair <string, HashSet <object> > categories = subCategories.First(); Dictionary <string, HashSet <object> > remainingSubCategories = new Dictionary <string, HashSet <object> >(subCategories); remainingSubCategories.Remove(categories.Key); foreach (object category in categories.Value) { List <KeyValuePair <string, object> > newParentCategories = new List <KeyValuePair <string, object> >(parentCategories); newParentCategories.Add(new KeyValuePair <string, object>(categories.Key, category)); if (remainingSubCategories.Count > 0) { dictionary[category] = buildSubDictionaries(newParentCategories, remainingSubCategories, aggregatedData); } else { List <AggregatedData <T> > filteredData = aggregatedData; foreach (KeyValuePair <string, object> parentCategory in newParentCategories) { filteredData = (from AggregatedData <T> datum in filteredData where datum.AggregatorValues.ContainsKey(parentCategory.Key) && datum.AggregatorValues[parentCategory.Key] == parentCategory.Value select datum).ToList(); } dictionary[category] = (from AggregatedData <T> datum in filteredData select datum.Data).ToList(); } } return(output); }
public static AnnotatedObject <Geometry>[] GetGeomsFromGeoJson(string geoJson) { List <AnnotatedObject <Geometry> > output = new List <AnnotatedObject <Geometry> >(); GeoJsonReader reader = new GeoJsonReader(GeometryFactory.Default, new JsonSerializerSettings()); ProtoGeoJSON obj = reader.Read <ProtoGeoJSON>(geoJson); AnnotatedObject <Geometry> annotatedGeom = new AnnotatedObject <Geometry>(null); Geometry geom; bool isFeatureCollection = false; switch (obj.Type) { case "Point": annotatedGeom.Object = reader.Read <Point>(geoJson); break; case "LineString": annotatedGeom.Object = reader.Read <LineString>(geoJson); break; case "Polygon": annotatedGeom.Object = reader.Read <NetTopologySuite.Geometries.Polygon>(geoJson); break; case "MultiPoint": annotatedGeom.Object = reader.Read <MultiPoint>(geoJson); break; case "MultiLineString": annotatedGeom.Object = reader.Read <MultiLineString>(geoJson); break; case "MultiPolygon": annotatedGeom.Object = reader.Read <MultiPolygon>(geoJson); break; case "Feature": Feature feature = reader.Read <Feature>(geoJson); annotatedGeom.Object = feature.Geometry; foreach (string attribute in feature.Attributes.GetNames()) { annotatedGeom.Data[attribute] = feature.Attributes[attribute]; } break; case "FeatureCollection": FeatureCollection collection = reader.Read <FeatureCollection>(geoJson); foreach (Feature item in collection) { annotatedGeom = new AnnotatedObject <Geometry>(item.Geometry); annotatedGeom.Object.Normalize(); foreach (string attribute in item.Attributes.GetNames()) { annotatedGeom.Data[attribute] = item.Attributes[attribute]; } output.Add(annotatedGeom); } isFeatureCollection = true; break; default: throw new NotImplementedException(string.Format("No handler found for type {0}", obj.Type)); } if (!isFeatureCollection) { annotatedGeom.Object.Normalize(); output.Add(annotatedGeom); } return(output.ToArray()); }