/// <summary> /// Tests for previous bitmap. none == -1, blank == 0, full == 1 /// </summary> /// <param name="quadTree"></param> /// <returns></returns> int previousBitmap(string quadTree) { string dir = @"C:\data\" + dirType + @"\images\"; GlobalMercator projection = new GlobalMercator(); int[] tileXYZ = projection.quadKeyToTileXY(quadTree); // bitmap.Save(@"C:\data\HousePricesDownload\web\images\"+tileXYZ[2]+"/"+tileXYZ[0]+"/"+tileXYZ[1]+".png"); string pathString = dir + tileXYZ[2] + "/" + tileXYZ[0] + "/" + tileXYZ[1] + ".png"; bool previous = System.IO.File.Exists(pathString); if (!previous) { return(-1); } bool blank = isBlank(pathString); if (blank) { return(0); } else { return(1); } }
static async Task <long> queryLand(string quadTree, IMongoCollection <BsonDocument> collection) { //filters for square footage string dirType = "land"; GlobalMercator proj = new GlobalMercator(); int[] tileXYZ = proj.quadKeyToTileXY(quadTree); System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(256, 256); long count = 0; int zoom = quadTree.Length; var builder = Builders <BsonDocument> .Filter; var regex = new BsonRegularExpression(string.Format("^{0}", quadTree)); var filter = Builders <BsonDocument> .Filter.Regex("quad", regex); var filterGt = Builders <BsonDocument> .Filter.Gt("sf", 0); filter = filter & builder.Not(filterGt); using (var cursor = await collection.FindAsync(filter)) { while (await cursor.MoveNextAsync()) { var batch = cursor.Current; foreach (var doc in batch) { if (doc["price"].BsonType != BsonType.Int32) { continue; } double p = (double)doc["price"].AsInt32; // double sf = (double) doc["sf"].AsInt32; double latitude = (double)doc["lat"].AsDouble; double longitude = (double)doc["lng"].AsDouble; // double ppsf = p/sf; Draw.near(p, 5000, 800000, latitude, longitude, zoom, bitmap); //Draw.price(ppsf, latitude, longitude, zoom, bitmap); //Draw.near(ppsf, 50, 250, latitude,longitude,zoom, bitmap); //Draw.near(doc["price"].AsInt32, doc["nearMin"].AsInt32, doc["nearMax"].AsInt32, doc["lat"].AsDouble, doc["lng"].AsDouble, zoom, bitmap); } } } ////save bitmap string pathString = @"C:\data\" + dirType + @"\images\" + tileXYZ[2] + "/" + tileXYZ[0] + "/"; System.IO.Directory.CreateDirectory(pathString); bitmap.Save(@"C:\data\" + dirType + @"\images\" + tileXYZ[2] + "/" + tileXYZ[0] + "/" + tileXYZ[1] + ".png"); return(count); }
static async Task <long> queryToBitmap3(string quadTree, IMongoCollection <BsonDocument> collection, string dirType) { GlobalMercator proj = new GlobalMercator(); int[] tileXYZ = proj.quadKeyToTileXY(quadTree); System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(256, 256); long count = 0; int zoom = quadTree.Length; var builder = Builders <BsonDocument> .Filter; var regex = new BsonRegularExpression(string.Format("^{0}", quadTree)); var filter = Builders <BsonDocument> .Filter.Regex("quad", regex); //filter = filter & builder.Lt("lng", bounds[3]); //filter = filter & builder.Exists("nearMin",true); filter = filter & builder.Gt("sf", 0); //var result = await collection.Find(filter).ToListAsync(); using (var cursor = await collection.FindAsync(filter)) { while (await cursor.MoveNextAsync()) { var batch = cursor.Current; foreach (var doc in batch) { if (doc["price"].BsonType != BsonType.Int32) { continue; } int p = (int)doc["price"].AsInt32; double latitude = (double)doc["lat"].AsDouble; double longitude = (double)doc["lng"].AsDouble; Draw.price(p, latitude, longitude, zoom, bitmap); //Draw.near(doc["price"].AsInt32, doc["nearMin"].AsInt32, doc["nearMax"].AsInt32, doc["lat"].AsDouble, doc["lng"].AsDouble, zoom, bitmap); } } } ////save bitmap string pathString = @"C:\data\HousePricesDownload\web\images\" + tileXYZ[2] + "/" + tileXYZ[0] + "/"; System.IO.Directory.CreateDirectory(pathString); bitmap.Save(@"C:\data\HousePricesDownload\web\images\" + tileXYZ[2] + "/" + tileXYZ[0] + "/" + tileXYZ[1] + ".png"); return(count); }