Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
x3domlet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Elphel
x3domlet
Commits
e837057d
Commit
e837057d
authored
Aug 24, 2017
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
copying selected models
parent
b480ea74
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
2 deletions
+150
-2
select.js
js/select.js
+24
-1
select.html
select.html
+6
-0
select.php
select.php
+120
-1
No files found.
js/select.js
View file @
e837057d
...
@@ -15,6 +15,10 @@ $(function(){
...
@@ -15,6 +15,10 @@ $(function(){
});
});
$
(
'.copy'
).
on
(
'click'
,
function
(
e
){
copy_models
();
});
});
});
function
parse_list
(
res
){
function
parse_list
(
res
){
...
@@ -29,10 +33,12 @@ function parse_list(res){
...
@@ -29,10 +33,12 @@ function parse_list(res){
$
(
this
).
find
(
"model"
).
each
(
function
(){
$
(
this
).
find
(
"model"
).
each
(
function
(){
var
mname
=
$
(
this
).
attr
(
"name"
);
var
mname
=
$
(
this
).
attr
(
"name"
);
var
basepath
=
'models/_all/'
+
name
;
var
item
=
[
var
item
=
[
'<li>'
,
'<li>'
,
' <a href=
\'
viewer.html?basepath=models/_all/'
+
name
+
'&path='
+
mname
+
'
\'
>'
+
mname
+
'</a>'
,
' <input type=
\'
checkbox
\'
class=
\'
chkbox
\'
set=
\'
'
+
name
+
'
\'
model=
\'
'
+
mname
+
'
\'
/>'
,
' <a href=
\'
viewer.html?basepath='
+
basepath
+
'&path='
+
mname
+
'
\'
>'
+
mname
+
'</a>'
,
'</li>'
'</li>'
].
join
(
'
\
n'
);
].
join
(
'
\
n'
);
...
@@ -43,3 +49,20 @@ function parse_list(res){
...
@@ -43,3 +49,20 @@ function parse_list(res){
});
});
}
}
function
copy_models
(){
$
(
".chkbox"
).
each
(
function
(){
if
(
$
(
this
).
prop
(
"checked"
)){
$
.
ajax
({
url
:
"select.php?cmd=copy&set="
+
$
(
this
).
attr
(
'set'
)
+
"&model="
+
$
(
this
).
attr
(
'model'
),
success
:
function
(
response
){
console
.
log
(
response
);
}
});
}
});
}
\ No newline at end of file
select.html
View file @
e837057d
...
@@ -21,7 +21,13 @@
...
@@ -21,7 +21,13 @@
</head>
</head>
<body>
<body>
<div>
<button
class=
'copy'
>
Copy checked to
<i>
models/
</i></button>
</div>
<div
id=
"content"
>
<div
id=
"content"
>
</div>
</div>
<div>
<button
class=
'copy'
>
Copy checked to
<i>
models/
</i></button>
</div>
</body>
</body>
</html>
</html>
select.php
View file @
e837057d
<?php
<?php
$base
=
"models/_all"
;
$base0
=
"models"
;
$base
=
"
$base0
/_all"
;
$showall
=
false
;
$showall
=
false
;
...
@@ -8,6 +9,47 @@ if (isset($_GET['showall'])){
...
@@ -8,6 +9,47 @@ if (isset($_GET['showall'])){
$showall
=
true
;
$showall
=
true
;
}
}
if
(
$_GET
[
'cmd'
]
==
'copy'
){
$set
=
$_GET
[
'set'
];
$model
=
$_GET
[
'model'
];
$path_from
=
"
$base
/
$set
/
$model
/*"
;
$path_to
=
"
$base0
/
$model
/v0"
;
if
(
!
is_dir
(
$path_to
)){
$old
=
umask
(
0
);
$res
=
mkdir
(
$path_to
,
0777
,
true
);
umask
(
$old
);
if
(
!
$res
){
die
(
"FAIL:
$set
/
$model
: check 'w' rights on models/"
);
}
}
exec
(
"cp -r
$path_from
$path_to
"
);
//generate default kml
$ts
=
str_replace
(
"_"
,
"."
,
$model
);
$kml
=
"
$base0
/
$model
/
$model
.kml"
;
if
(
!
is_file
(
$kml
)){
file_put_contents
(
$kml
,
generate_default_kml
(
$model
,
$ts
));
}
//gen thumbnail
$thumb_src
=
"
$base0
/
$model
/v0/
$model
-00-D0.0.jpeg"
;
$thumb_res
=
"
$base0
/
$model
/thumb.jpeg"
;
if
(
!
is_file
(
$thumb_res
)){
if
(
is_file
(
$thumb_src
)){
create_thumbnail
(
$thumb_src
,
$thumb_res
);
}
}
die
(
"DONE:
$set
/
$model
was copied to models/"
);
}
$series
=
selective_scandir
(
$base
,
false
);
$series
=
selective_scandir
(
$base
,
false
);
$res
=
""
;
$res
=
""
;
...
@@ -67,4 +109,81 @@ function return_xml($str){
...
@@ -67,4 +109,81 @@ function return_xml($str){
}
}
function
generate_default_kml
(
$name
,
$ts
){
$kml
=
<<<TXT
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<PhotoOverlay>
<name>$name</name>
<visibility>1</visibility>
<shape>rectangle</shape>
<TimeStamp>
<when>$ts</when>
</TimeStamp>
<Camera>
<longitude>-111.9328843</longitude>
<latitude>40.7233861</latitude>
<altitude>1305.1</altitude>
<heading>65</heading>
<tilt>90</tilt>
<roll>00</roll>
</Camera>
<Icon>
<href>x3d/$name.x3d</href>
</Icon>
<ExtendedData>
<OriginalData>
<longitude>-111.9328843</longitude>
<latitude>40.7233861</latitude>
<altitude>1305.1</altitude>
<heading>65</heading>
<tilt>90</tilt>
<roll>0</roll>
</OriginalData>
</ExtendedData>
</PhotoOverlay>
</Document>
</kml>
TXT;
return
$kml
;
}
function
create_thumbnail
(
$path
,
$thumbname
){
$file
=
$path
;
if
(
extension_loaded
(
'imagick'
)){
$imagick
=
new
Imagick
(
$file
);
$imagick
->
trimImage
(
0
);
$w
=
$imagick
->
getImageWidth
();
$h
=
$imagick
->
getImageHeight
();
//$imagick->borderImage('black', 100, 100);
// $imagick->cropImage($w/2, $h/4, $w/4, $h/4);
//$imagick->thumbnailImage(200, 100, true, true);
$imagick
->
cropThumbnailImage
(
198
,
98
);
$imagick
->
borderImage
(
'gray'
,
1
,
1
);
$imagick
->
writeImage
(
$thumbname
);
}
else
{
echo
"Extension imagick is no loaded.
\n
"
;
}
return
0
;
}
?>
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment