Skip to content

Commit

Permalink
japan-niji-mesh loader
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuque committed Feb 24, 2014
1 parent 165233f commit 15f1878
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
39 changes: 37 additions & 2 deletions inner/js/data/MeshCSVLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ if (!window.mobmap) { window.mobmap={}; }
md.originLng = 100;

switch(meshLevel) {
case 2:
// 2-ji (1/8 of 1-ji)
md.stepLat = (1.0 / 1.5) / 8.0;
md.stepLng = (1.0 ) / 8.0;
break;

default:
// 1-ji
md.stepLat = 1.0 / 1.5;
Expand Down Expand Up @@ -156,11 +162,40 @@ if (!window.mobmap) { window.mobmap={}; }
},

calcLatIndexFromMeshCode: function(meshCode) {
return Math.floor(meshCode / 100);
var index = 0;
switch (this.usingMeshCode.level) {
case 2:
var i1 = Math.floor(meshCode / 10000);
var yx2 = meshCode % 100;
var i2 = Math.floor(yx2 / 10);

index = i1 * 8 + i2;

break;

default:
index = Math.floor(meshCode / 100); break;
}

return index;
},

calcLngIndexFromMeshCode: function(meshCode) {
return meshCode % 100 ;
var index = 0;
switch (this.usingMeshCode.level) {
case 2:
var i1 = Math.floor(meshCode / 100) % 100;
var i2 = meshCode % 10;

index = i1 * 8 + i2;

break;

default:
index = meshCode % 100; break;
}

return index;
},

// callbacks - - - - - - - - - - - - -
Expand Down
2 changes: 1 addition & 1 deletion inner/js/data/mesh-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (!window.mobmap) window.mobmap={};
var cell = m[k];
return cell.pickAtTime(tSeconds);
} else {
return 0;
return null;
}
},

Expand Down
11 changes: 7 additions & 4 deletions inner/js/map/MeshCanvasOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,14 @@ if (!window.mobmap) { window.mobmap={}; }
}

var cellVal = md.pick(y, x, this.pickTime);
var cellColor = this.mapValueToCellColor(cellVal.val);
g.fillStyle = cellColor;
if (cellVal) {
var cellColor = this.mapValueToCellColor(cellVal.val);
g.fillStyle = cellColor;

g.fillRect(sx1, sy2, (sx2-sx1), (sy1-sy2));
// g.clearRect(sx1+1, sy2+1, (sx2-sx1)-2, (sy1-sy2)-2);
g.fillRect(sx1, sy2, (sx2-sx1), (sy1-sy2));
// g.clearRect(sx1+1, sy2+1, (sx2-sx1)-2, (sy1-sy2)-2);
}

}
}
};
Expand Down

0 comments on commit 15f1878

Please sign in to comment.