Commit 663ee0fc authored by Scott Sun's avatar Scott Sun

s

parent c876d2dd
function getFeaturesSurface(arr) {
var surface_index = 1;
var surface = {};
var tmp_array = arr
var surface_points = []
for(var i=0; i<tmp_array.length;i++) {
if(/^#S\s+P/.test(tmp_array[i])){
var tmp = tmp_array[i].split(/\,/)
if(!surface[surface_index]){surface[surface_index] = {}}
surface[surface_index]["attributes"] = tmp
}
if(/^#\d+\s+#S\s+P/.test(tmp_array[i])){
var tmp = tmp_array[i].split(/\,/)
if(!surface[surface_index]){surface[surface_index] = {}}
surface[surface_index]["attributes"] = tmp
surface[surface_index]["serial"] = /#(\d+)/.exec(tmp_array[i])[1]
}
var tmp=tmp_array[i].split(/\s+/)
console.log(tmp);
if(tmp[0]==="#" || /^#\d+$/.test(tmp[0])){
tmp = tmp.slice(1)
}
if (/^#OB|^#\s+#OB/.test(tmp_array[i]) || /^#OS|^#\s+#OS/.test(tmp_array[i])) {
if (/^#OB|^#\s+#OB/.test(tmp_array[i])) {
if(!surface[surface_index]){surface[surface_index] = {}}
surface[surface_index].type = tmp[3]
}
surface_points.push({x:tmp[1],y:tmp[2],arcx:undefined,arcy:undefined,arcdir:undefined})
}else if (/^#OC|^#\s+#OC/.test(tmp_array[i])) {
surface_points.push({x:tmp[1],y:tmp[2],arcx:tmp[3],arcy:tmp[4],arcdir:tmp[5]})
}
if (/^#OE|^#\s+#OE/.test(tmp_array[i])) {
if(!surface[surface_index]){surface[surface_index] = {}}
surface[surface_index].coordinates = surface_points
surface[surface_index].points_num = surface_points.length
surface_index++;
surface_points = []
}
}
return surface
}
// #OB #OS #OE
console.log(getFeaturesSurface(
[
"### Layer - tmp features data ###",
"#26 #S P 0",
"# #OB 5.687356102362 3.734867322835 I",
"# #OS 5.687356102362 4.881030511811",
"# #OS 6.477813484252 4.881030511811",
"# #OS 6.477813484252 3.734867322835",
"# #OS 5.687356102362 3.734867322835",
"# #OE",
"#27 #S P 0",
"# #OB 4.514844389764 4.459453248031 I",
"# #OS 4.64658730315 3.91930738189",
"# #OS 4.751981594488 3.418684350394",
"# #OS 4.264532874016 2.66774980315",
"# #OS 2.933929625984 3.892958759843",
"# #OS 4.514844389764 4.459453248031",
"# #OE",
]
))
/*
#28 #S P 0
# #OB 1.063180511811 6.119413681102 I
# #OS 2.775838188976 5.236736318898
# #OS 2.670443799213 4.354058858268
# #OS 0.694300393701 5.104993405512
# #OS 1.063180511811 6.119413681102
# #OE
#29 #S P 0
# #OB 1.695546456693 2.628226968504 I
# #OS 1.985380807087 1.468889468504
# #OS 1.326666338583 1.626981003937
# #OS 1.695546456693 2.628226968504
# #OE
#30 #S P 0
# #OB 5.357998917323 1.798246751969 I
# #OS 5.753227559055 1.205403740157
# #OS 4.896898818898 1.086835137795
# #OS 5.357998917323 1.798246751969
# #OE
#31 #S P 0
# #OB 7.966508267717 2.812667027559 I
# #OS 7.768893897638 2.24617253937
# #OS 7.347316633858 2.746795570866
# #OS 7.966508267717 2.812667027559
# #OE
#32 #S P 0
# #OB 7.729371062992 5.737359251969 I
# #OS 7.492233759843 5.289433464567
# #OS 7.479059547244 5.671487893701
# #OS 7.729371062992 5.737359251969
# #OE
*/
\ No newline at end of file
var tmp = {}
console.log(tmp instanceof Object)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment