У меня есть квадрат 1км, я делю его на 100 метров как на положительные, так и на отрицательные стороны ..
__________y__________
| | |
| | |
| | |
|---------|---------| x
| | |
| | |
|_________|_________|
По сути, я делаю квадрат, как показано выше. Я погружаю его в 100-метровые квадраты как с положительной, так и с отрицательной стороны оси X. Затем я строю график каждой точки в их соответствующих координатах, я планирую бросить значение (x, y) через кучу операторов if / else (по крайней мере, от 50 до 100), но меня интересует, как дорого это будет. Есть ли более эффективный способ делать то, что я хочу сделать?
Вот пример того, как я планирую это сделать ...
if(tlat < lat && tlat > lat - 89930.7){
//point is within 100 meters on lat
//On the NEGATIVE SIDE.
if(tlng > lng && tlng < lng + 147999.8){
//point is within 100 meters on lat NEGATIVE &&
//withing 100 meters on lng POSITIVE
layers.addcube(highlng100p, lowlng100p, yhigh, ylow, highlat100p, lowlat100p);
highlng100p = highlng100p + 5;
lowlng100p = lowlng100p + 5;
highlat100p = highlat100p + 5;
lowlat100p = lowlat100p + 5;
}else if(tlng < lng && tlng > lng - 147999.8){
//point is within 100 meters on lat NEGATIVE &&
//withing 100 meters on lng NEGATIVE
layers.addcube(highlat100n, lowlat100n, yhigh, ylow, highlng100n, lowlng100n);
highlat100n = highlat100n + 5;
lowlat100n = lowlat100n + 5;
highlng100n = highlng100n + 5;
lowlat100n = lowlat100n + 5;
}else if(tlng > lng && tlng < lng + 295999.6){
//point is within 200 meters on lat NEGATIVE &&
//withing 200 meters on lng POSITIVE
layers.addcube(highlat200n, lowlat200n, yhigh, ylow, highlng200p, lowlng200n);
highlat200n = highlat200n + 5;
lowlat200n = lowlat200n + 5;
highlng200p = highlng200p + 5;
lowlng200p = lowlng200p + 5;
}else if(tlng < lng && tlng > lng - 295999.6){
//point is within 200 meters on lat NEGATIVE &&
//withing 200 meters on lng NEGATIVE
layers.addcube(highlat200n, lowlat200n, yhigh, ylow, highlng200n, lowlng200n);
highlat200n = highlat200n + 5;
lowlat200n = lowlat200n + 5;
highlng200n = highlng200n + 5;
lowlng200n = lowlng200n + 5;
}else if(tlng > lng && tlng < lng + 443999.4){
//point is within 300 meters on lat NEGATIVE &&
//withing 300 meters on lng POSITIVE
layers.addcube(highlat300n, lowlat300n, yhigh, ylow, highlng300p, lowlng300p);
highlat300n = highlat300n + 5;
lowlat300n = lowlat300n + 5;
highlng300p = highlng300p + 5;
lowlng300p = lowlng300p + 5;
}else if(tlng < lng && tlng > lng - 443999.4){
//point is within 300 meters on lat NEGATIVE &&
//withing 300 meters on lng NEGATIVE
layers.addcube(highlat300n, lowlat300n, yhigh, ylow, highlng300n, lowlng300n);
highlat300n = highlat300n + 5;
lowlat300n = lowlat300n + 5;
highlng300n = highlng300n + 5;
lowlng300n = lowlng300n + 5;
} else if(tlng > lng && tlng < lng + 591999.2){
//point is within 400 meters on lng
//on the POSITIVE SIDE
layers.addcube(highlat400n, lowlat400n, yhigh, ylow, highlng400p, lowlng400p);
highlat400n = highlat400n + 5;
lowlat400n = lowlat400n + 5;
highlng400p = highlng400p + 5;
lowlng400p = lowlng400p + 5;
}else if(tlng < lng && tlng > lng - 591999.2){
//point is within 400 meters on lng
//on the NEGATIVE SIDE
layers.addcube(highlat400n, lowlat400n, yhigh, ylow, highlng400n, lowlng400n);
highlat400n = highlat400n + 5;
lowlat400n = lowlat400n + 5;
highlng400n = highlng400n + 5;
lowlng400n = lowlng400n + 5;
}else if(tlng > lng && tlng < lng + 739999){
//point is within 500 meters on lng
//on the POSITIVE SIDE
layers.addcube(highlat500n, lowlat500n, yhigh, ylow, highlng500p, lowlng500p);
highlat500n = highlat500n + 5;
lowlat500n = lowlat500n + 5;
highlng500p = highlng500p + 5;
lowlng500p = lowlng500p + 5;
}else if(tlng < lng && tlng > lng - 739999){
//point is within 500 meters on lng
//on the NEGATIVE SIDE
layers.addcube(highlat500n, lowlat500n, yhigh, ylow, highlng500n, lowlng500n);
highlat500n = highlat500n + 5;
lowlat500n = lowlat500n + 5;
highlng500n = highlng500n + 5;
lowlng500n = lowlng500n + 5;
}
}
Если бы кто-нибудь мог помочь мне сделать то, что я хочу сделать, гораздо более эффективным, я был бы признателен за это!
Спасибо,