Hello everyone

I have a geoJson file with arrays of coordinates ( Longitude , Latitude , z ), I want to know is it possible to make a triangle mesh with Longitude, Latitude and z? or should I convert all of them to meter?

Hello everyone

I have a geoJson file with arrays of coordinates ( Longitude , Latitude , z ), I want to know is it possible to make a triangle mesh with Longitude, Latitude and z? or should I convert all of them to meter?

possibly we would need to see your dataset though.

1 Like

hey arash he is iranian right i am so glad see you here

1 Like

I think this should help:

1 Like

Thank you so much @Evgeni_Popov, I wanted to know is it any way to use it with babylonJS? , because its almost like arcRotateCamera location base.

You need to convert the python code to javascript, but it should be straightforward, just prefix with `Math.`

the trigonometric functions and replace `c4d.vector`

by `BABYLON.Vector3`

.

1 Like

Hi, Thanks a lot.

these are parts of the GeoJSON file :

[

{

“type”: “Feature”,

“geometry”: {

“type”: “GeometryCollection”,

“geometries”: [

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.67365, 58.43086, 5247.6],

[-4.68345, 58.43669, 3850.5],

[-4.66852, 58.42488, 2523.2],

[-4.67365, 58.43086, 5247.6]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.67365, 58.43086, 5247.6],

[-4.66889, 58.42739, 5176.2],

[-4.66852, 58.42488, 2523.2],

[-4.67365, 58.43086, 5247.6]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.66478, 58.42441, 5127.4],

[-4.66852, 58.42488, 2523.2],

[-4.65904, 58.41819, 2639.8],

[-4.66478, 58.42441, 5127.4]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.66478, 58.42441, 5127.4],

[-4.65982, 58.42082, 5074.7],

[-4.65904, 58.41819, 2639.8],

[-4.66478, 58.42441, 5127.4]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.66478, 58.42441, 5127.4],

[-4.66852, 58.42488, 2523.2],

[-4.66754, 58.42642, 5158.1],

[-4.66478, 58.42441, 5127.4]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.66889, 58.42739, 5176.2],

[-4.66754, 58.42642, 5158.1],

[-4.66852, 58.42488, 2523.2],

[-4.66889, 58.42739, 5176.2]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.65904, 58.41819, 2639.8],

[-4.6592, 58.42037, 5071.8],

[-4.65982, 58.42082, 5074.7],

[-4.65904, 58.41819, 2639.8]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.67365, 58.43086, 5247.6],

[-4.68345, 58.43669, 3850.5],

[-4.67795, 58.43403, 5341.8],

[-4.67365, 58.43086, 5247.6]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.68345, 58.43669, 3850.5],

[-4.69912, 58.44885, 4974.8],

[-4.69197, 58.44421, 5532],

[-4.68345, 58.43669, 3850.5]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.68345, 58.43669, 3850.5],

[-4.68702, 58.44061, 5457.3],

[-4.69197, 58.44421, 5532],

[-4.68345, 58.43669, 3850.5]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.68586, 58.43977, 5443],

[-4.68345, 58.43669, 3850.5],

[-4.67795, 58.43403, 5341.8],

[-4.68586, 58.43977, 5443]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.68345, 58.43669, 3850.5],

[-4.68586, 58.43977, 5443],

[-4.68702, 58.44061, 5457.3],

[-4.68345, 58.43669, 3850.5]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.68586, 58.43977, 5443],

[-4.68347, 58.43804, 5417],

[-4.67795, 58.43403, 5341.8],

[-4.68586, 58.43977, 5443]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.69197, 58.44421, 5532],

[-4.69912, 58.44885, 4974.8],

[-4.69609, 58.44718, 5551.8],

[-4.69197, 58.44421, 5532]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.67795, 58.43403, 5341.8],

[-4.67976, 58.43535, 5381.5],

[-4.68347, 58.43804, 5417],

[-4.67795, 58.43403, 5341.8]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.65982, 58.42082, 5074.7],

[-4.66144, 58.422, 5099.6],

[-4.66478, 58.42441, 5127.4],

[-4.65982, 58.42082, 5074.7]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.69609, 58.44718, 5551.8],

[-4.69912, 58.44885, 4974.8],

[-4.69808, 58.44859, 5543.7],

[-4.69609, 58.44718, 5551.8]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.70217, 58.45152, 5549.8],

[-4.70336, 58.45206, 5183],

[-4.69912, 58.44885, 4974.8],

[-4.70217, 58.45152, 5549.8]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.70217, 58.45152, 5549.8],

[-4.69808, 58.44859, 5543.7],

[-4.69912, 58.44885, 4974.8],

[-4.70217, 58.45152, 5549.8]

]

]

},

{

“type”: “Polygon”,

“coordinates”: [

[

[-4.71029, 58.45737, 5602.1],

[-4.70516, 58.45367, 5562.6],

[-4.70716, 58.45488, 5300.2],

[-4.71029, 58.45737, 5602.1]

]

]

},

}

Thank you so much, there is also another problem which is the Earth isn’t exactly sphere.

Thanks a lot.

i change some of your data because all point is so close

for explain how you can make them

you can use this methods

var _null = ‘helper for exact null value’;

function def(a, d) {

if (a != undefined && a != null) return (d != undefined && d != null ? a : true);

else

if (d != _null)

return (d != undefined && d != null ? d : false);

return null;

}

function rotate_xy(pr1, pr2, alpha) {

pp2 = { x: pr2.x - pr1.x, y: pr2.y - pr1.y };

```
return {
x: pr1.x + pp2.x * cos(alpha) - pp2.y * sin(alpha),
y: pr1.y + pp2.x * sin(alpha) + pp2.y * cos(alpha)
};
```

}

function r_y(n, a, c) {

```
c = def(c, { x: 0, y: 0, z: 0 });
var c1 = { x: c.x, y: c.y, z: c.z };
c1.x = c1.x;
c1.y = c1.z;
var p = rotate_xy(c1, { x: n.x, y: n.z }, a);
n.x = p.x;
n.z = p.y;
return n;
```

}

function r_x(n, a, c) {

```
c = def(c, { x: 0, y: 0, z: 0 });
var c1 = { x: c.x, y: c.y, z: c.z };
c1.x = c1.y;
c1.y = c1.z;
var p = rotate_xy(c1, { x: n.y, y: n.z }, a);
n.y = p.x;
n.z = p.y;
return n;
```

}

function r_z(n, a, c) {

```
c = def(c, { x: 0, y: 0, z: 0 });
var c1 = { x: c.x, y: c.y, z: c.z };
var p = rotate_xy(c1, { x: n.x, y: n.y }, a);
n.x = p.x;
n.y = p.y;
return n;
```

}

// final function for convert geoPos to pos

// use scale = 0.001 for see the better result

// deg =0.017453292519943295 convert your deg to rad

function pos( geoP){

```
var p = { x: 0, z: 0, y: 0 };
p.z = (geoP[2]*scale);
p = r_x(p,geoP[0]*deg);
p = r_y(p,geoP[1]*deg);
return p;
```

}

2 Likes

Thank you so much @nasimiasl, Its great. Thank you for devoting your time to answering my question and helping me to increase my knowledge on this question.

1 Like

we use each other knowledge for learn in this forum so thanks from Bjs community

3 Likes