public override NeighborhoodShape GetFeatureLookup(double x, double y) { // Validate Point is in Range var point = new Point(x, y); var model = new NeighborhoodShape(); var features = GetFeatures(); foreach (var f in features) { var exists = f.Geometry.Contains(point); if (exists) { model = new NeighborhoodShape { BoroCode = int.Parse(f.Attributes["BoroCode"].ToString()), BoroName = f.Attributes["BoroName"].ToString(), CountyFIPS = f.Attributes["CountyFIPS"].ToString(), NTACode = f.Attributes["NTACode"].ToString(), NTAName = f.Attributes["NTAName"].ToString(), }; } } if (!model.ArePropertiesNotNull()) { return(null); } return(model); }
public void Update() { // TODO: There's probably something better to check here if (currentShape.center.centerPoint.x > camera.transform.position.x) { // if (false) { if (mediumShape != null) { oldShape = mediumShape; } mediumShape = currentShape; Neighborhood centerOfShape = currentShape.center; float spawnX = (centerOfShape.bottomLeft.x - totalOffset) + (centerOfShape.blockOffset / 2); float spawnZ = (centerOfShape.bottomLeft.z + totalOffset) + (centerOfShape.blockOffset / 2); currentShape = SpawnNeighborhoodShape(spawnX, spawnZ, mediumShape); if (oldShape != null) { neighborhoods.Remove(oldShape.center.gameObject.GetComponent <Neighborhood>()); Destroy(oldShape.center.gameObject); neighborhoods.Remove(oldShape.top.gameObject.GetComponent <Neighborhood>()); Destroy(oldShape.top.gameObject); neighborhoods.Remove(oldShape.left.gameObject.GetComponent <Neighborhood>()); Destroy(oldShape.left.gameObject); } } for (int i = 0; i < neighborhoods.Count; i++) { neighborhoods[i].Move(); } }
public NeighborhoodShape SpawnNeighborhoodShape(float x, float z, NeighborhoodShape prevShape) { Neighborhood center = Instantiate(neighborhoodPrefab, Vector3.zero, Quaternion.identity).GetComponent <Neighborhood>(); Neighborhood top = Instantiate(neighborhoodPrefab, Vector3.zero, Quaternion.identity).GetComponent <Neighborhood>(); Neighborhood left = Instantiate(neighborhoodPrefab, Vector3.zero, Quaternion.identity).GetComponent <Neighborhood>(); neighborhoods.Add(center); neighborhoods.Add(top); neighborhoods.Add(left); NeighborhoodShape shape = new NeighborhoodShape(center, top, left); shape.previousShape = prevShape; if (prevShape != null) { prevShape.nextShape = shape; } center.transform.position = new Vector3(x, 0f, z); top.transform.position = new Vector3(x, 0f, z + totalOffset); left.transform.position = new Vector3(x - totalOffset, 0f, z); shape.Build(); return(shape); }
public void Start() { Physics.autoSimulation = false; camera = Camera.main; Screen.SetResolution(200, 200, false); Neighborhood neighborhood = neighborhoodPrefab.GetComponent <Neighborhood>(); // We could create a separate height and width offset but lets keep it simple totalOffset = neighborhood.blockOffset * neighborhood.height; radius = totalOffset / 2; currentShape = SpawnNeighborhoodShape(0f + neighborhood.blockOffset / 2, 0f + neighborhood.blockOffset / 2, null); }
public IEnumerable <NeighborhoodShape> GetFeatureAttributes() { var features = GetFeatures(); var results = new List <NeighborhoodShape>(features.Count); foreach (var f in features) { var model = new NeighborhoodShape { BoroCode = int.Parse(f.Attributes["BoroCode"].ToString()), BoroName = f.Attributes["BoroName"].ToString(), CountyFIPS = f.Attributes["CountyFIPS"].ToString(), NTACode = f.Attributes["NTACode"].ToString(), NTAName = f.Attributes["NTAName"].ToString(), }; results.Add(model); } return(results.OrderBy(x => x.BoroCode)); }