Commit 443ca6b75eb4c6c27b88343773125ed054108dd6
1 parent
0251baa2
Query is optimized for getting results based on zoom level and sytem
Showing
1 changed file
with
44 additions
and
0 deletions
400-SOURCECODE/AIAHTML5.API/Models/PixelLocator.cs.orig
0 → 100644
1 | +using MongoDB.Bson; | |
2 | +using MongoDB.Driver; | |
3 | +using System; | |
4 | +using System.Collections.Generic; | |
5 | +using System.Linq; | |
6 | +using System.Web; | |
7 | + | |
8 | +namespace AIAHTML5.API.Models | |
9 | +{ | |
10 | + public class PixelLocator | |
11 | + { | |
12 | + | |
13 | + internal static dynamic GetBodyRegionsPixelData(string layerNumber, string bodyViewIndex, string systemNumber, string zoom) | |
14 | + { | |
15 | + var client = new MongoClient(); | |
16 | + var db = client.GetDatabase("aia"); | |
17 | + var client = new MongoClient(); | |
18 | + | |
19 | + var col = db.GetCollection<BsonDocument>("DAImages"); | |
20 | + | |
21 | + var pipeline = new BsonDocument[] | |
22 | + { | |
23 | + new BsonDocument{{"$unwind", "$terms"}}, | |
24 | + new BsonDocument{ { "$match", new BsonDocument("terms.SystemNumbers", | |
25 | + Convert.ToInt32(systemNumber)).Add("bodyViewIndex", | |
26 | + Convert.ToInt32(bodyViewIndex)).Add("layerNumber", | |
27 | + Convert.ToInt32(layerNumber)).Add("zoom", | |
28 | + Convert.ToInt32(zoom)) }}, | |
29 | + new BsonDocument { {"$project", new BsonDocument() | |
30 | + .Add("_id", 0) | |
31 | + .Add("terms", 1) | |
32 | + .Add("bodyRegionId", 1) | |
33 | + } } | |
34 | + }; | |
35 | + | |
36 | + | |
37 | + var pixelData = col.Aggregate<BsonDocument>(pipeline).ToList(); | |
38 | + | |
39 | + return pixelData.ToJson(); | |
40 | + } | |
41 | + string error = e.Message+"..STACKTRACE: "+e.StackTrace; | |
42 | + return error; | |
43 | +} | |
44 | +} | ... | ... |