Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Caillat Michel
yafits
Commits
2e92f510
Commit
2e92f510
authored
Jan 09, 2020
by
Moreau Nicolas
Browse files
Merge branch 'master' into highcharts
parents
11bfdcc4
5328a223
Changes
13
Hide whitespace changes
Inline
Side-by-side
docker-compose.yml
View file @
2e92f510
...
@@ -6,7 +6,6 @@ services:
...
@@ -6,7 +6,6 @@ services:
ports
:
ports
:
-
"
${YAFITSV_PORT}:3000"
-
"
${YAFITSV_PORT}:3000"
volumes
:
volumes
:
-
"
${YAFITS_FITSDIR}:/home/partemix/dataroot/FITS"
-
"
${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
-
"
${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
-
"
${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
-
"
${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
-
"
${YAFITS_SAMPDIR}:/home/partemix/dataroot/SAMP"
-
"
${YAFITS_SAMPDIR}:/home/partemix/dataroot/SAMP"
...
@@ -22,16 +21,25 @@ services:
...
@@ -22,16 +21,25 @@ services:
-
yafitss
-
yafitss
yafitss
:
yafitss
:
build
:
./yafitss
build
:
context
:
./yafitss
args
:
YAFITS_FITSDIR
:
${YAFITS_FITSDIR}
YAFITS_FITSDIR2
:
${YAFITS_FITSDIR2}
image
:
yafitss:${USER}
image
:
yafitss:${USER}
ports
:
ports
:
-
"
${YAFITSS_PORT}:4251"
-
"
${YAFITSS_PORT}:4251"
volumes
:
volumes
:
-
"
${YAFITS_FITSDIR}:/home/partemix/dataroot/FITS"
-
"
${YAFITS_FITSDIR}:${YAFITS_FITSDIR}"
-
"
${YAFITS_FITSDIR2}:${YAFITS_FITSDIR2}"
-
"
${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
-
"
${YAFITS_PNGDIR}:/home/partemix/dataroot/PNG"
-
"
${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
-
"
${YAFITS_OBJDIR}:/home/partemix/dataroot/OBJ"
-
"
${YAFITS_LOGDIR}:/home/partemix/log"
-
"
${YAFITS_LOGDIR}:/home/partemix/log"
environment
:
environment
:
-
YAFITS_FITSDIR
-
YAFITS_FITSDIR2
-
YAFITSS_PORT=${YAFITSS_PORT}
-
YAFITSS_PORT=${YAFITSS_PORT}
-
YAFITSS_MAXIDLE=${YAFITSS_MAXIDLE}
-
YAFITSS_MAXIDLE=${YAFITSS_MAXIDLE}
command
:
python /home/partemix/yafitss/serverWsgi.py --port
4251
command
:
python /home/partemix/yafitss/serverWsgi.py --port
4251
yafits.bashrc.dist
View file @
2e92f510
...
@@ -13,6 +13,13 @@
...
@@ -13,6 +13,13 @@
#
#
export YAFITS_FITSDIR=/datartemix/ALMA/FITS
export YAFITS_FITSDIR=/datartemix/ALMA/FITS
#
# A way to extend the disk space allocated to FITS files
# by using symbolic links defined in YAFITS_FITSDIR towards files
# or directories located in YAFITS_FITSDIR2
#
export YAFITS_FITSDIR2=/datartemix2/ALMA/FITS
#
#
# Where will the temporary PNG files and log files be written.
# Where will the temporary PNG files and log files be written.
# Ensure that the directories are writable by anybody or at least
# Ensure that the directories are writable by anybody or at least
...
...
yafitss/DataBlock.py
View file @
2e92f510
...
@@ -1229,6 +1229,7 @@ class DataBlock:
...
@@ -1229,6 +1229,7 @@ class DataBlock:
result
[
"stdev"
]
=
{
"value"
:
np
.
nanstd
(
box
).
item
()
,
"unit"
:
bunit
}
result
[
"stdev"
]
=
{
"value"
:
np
.
nanstd
(
box
).
item
()
,
"unit"
:
bunit
}
result
[
"numpix"
]
=
{
"value"
:
np
.
count_nonzero
(
~
np
.
isnan
(
box
)),
"unit"
:
"pixels (!=Nan)"
}
result
[
"numpix"
]
=
{
"value"
:
np
.
count_nonzero
(
~
np
.
isnan
(
box
)),
"unit"
:
"pixels (!=Nan)"
}
result
[
"percentage of total number of pixels"
]
=
{
"value"
:
(
box
.
shape
[
0
]
*
box
.
shape
[
1
])
/
(
self
.
__header
[
"NAXIS1"
]
*
self
.
__header
[
"NAXIS2"
])
*
100
,
"unit"
:
"%"
}
result
[
"percentage of total number of pixels"
]
=
{
"value"
:
(
box
.
shape
[
0
]
*
box
.
shape
[
1
])
/
(
self
.
__header
[
"NAXIS1"
]
*
self
.
__header
[
"NAXIS2"
])
*
100
,
"unit"
:
"%"
}
result
[
"boundingRect"
]
=
{
"value"
:[
iRA0
,
iDEC0
,
iRA1
-
iRA0
,
iDEC1
-
iDEC0
],
"unit"
:
"pixels"
}
result
=
{
"status"
:
True
,
"message"
:
""
,
"result"
:
result
}
result
=
{
"status"
:
True
,
"message"
:
""
,
"result"
:
result
}
self
.
__logger
.
debug
(
"measureBox : exiting"
)
self
.
__logger
.
debug
(
"measureBox : exiting"
)
...
...
yafitss/Dockerfile
View file @
2e92f510
...
@@ -72,9 +72,20 @@ RUN echo "PATH=$PATH"
...
@@ -72,9 +72,20 @@ RUN echo "PATH=$PATH"
#------------------------------------------------------------#
#------------------------------------------------------------#
# Create some directories expected by the application.
# Create some directories expected by the application.
ARG
YAFITS_FITSDIR
ARG
YAFITS_FITSDIR2
ENV
YAFITS_FITSDIR=$YAFITS_FITSDIR
ENV
YAFITS_FITSDIR2=$YAFITS_FITSDIR2
# The root directory of the FITS files location (readonly). It'll have to be bound to an host directory.
# The root directory of the FITS files location (readonly). It'll have to be bound to an host directory.
RUN
mkdir
-p
/home/partemix/dataroot/FITS
RUN
printenv
RUN
sudo mkdir
-p
${
YAFITS_FITSDIR
}
RUN
sudo chown
partemix:partemix
${
YAFITS_FITSDIR
}
# The first extension to the root directory of FITS files location (readonly). It'll have to be bound to an host directory.
RUN
sudo mkdir
-p
${
YAFITS_FITSDIR2
}
RUN
sudo chown
partemix:partemix
${
YAFITS_FITSDIR2
}
# The root directory of the PNG files (read/write). It'll have to be bound to an host directory.
# The root directory of the PNG files (read/write). It'll have to be bound to an host directory.
RUN
mkdir
-p
/home/partemix/dataroot/PNG
RUN
mkdir
-p
/home/partemix/dataroot/PNG
...
...
yafitss/dataManager_michel.py
View file @
2e92f510
...
@@ -15,8 +15,9 @@ from datetime import datetime
...
@@ -15,8 +15,9 @@ from datetime import datetime
from
DataBlock
import
DataBlock
from
DataBlock
import
DataBlock
DataRoot
=
"dataroot"
FITSFilePrefix
=
os
.
getenv
(
"YAFITS_FITSDIR"
)
FITSFilePrefix
=
DataRoot
+
'/FITS/'
DataRoot
=
"/home/partemix/dataroot"
PNGFilePrefix
=
DataRoot
+
'/PNG/'
PNGFilePrefix
=
DataRoot
+
'/PNG/'
OBJFilePrefix
=
DataRoot
+
'/OBJ/'
OBJFilePrefix
=
DataRoot
+
'/OBJ/'
ApiDocPrefix
=
DataRoot
+
'/apidoc/'
ApiDocPrefix
=
DataRoot
+
'/apidoc/'
...
@@ -62,19 +63,29 @@ class DataManagerImpl :
...
@@ -62,19 +63,29 @@ class DataManagerImpl :
try
:
try
:
absFITSFilePrefix
=
FITSFilePrefix
+
relKey
absFITSFilePrefix
=
FITSFilePrefix
+
relKey
entries
=
(
os
.
listdir
(
absFITSFilePrefix
))
entries
=
(
os
.
listdir
(
absFITSFilePrefix
))
self
.
__logger
.
debug
(
"
type of entries %s"
%
(
type
(
entries
)
))
self
.
__logger
.
debug
(
"
%r"
%
entries
)
sortedEntries
=
entries
.
sort
()
sortedEntries
=
entries
.
sort
()
children
=
[]
children
=
[]
for
entry
in
entries
:
for
entry
in
entries
:
p
=
absFITSFilePrefix
+
'/'
+
entry
p
=
absFITSFilePrefix
+
'/'
+
entry
if
entry
.
startswith
(
"."
)
or
(
not
os
.
path
.
isdir
(
p
)
and
not
p
.
endswith
(
".fits"
))
:
condition
=
(
os
.
path
.
isfile
(
p
)
and
p
.
endswith
(
".fits"
))
if
not
condition
:
self
.
__logger
.
debug
(
"%s link %r"
%
(
p
,
os
.
path
.
islink
(
p
)))
if
os
.
path
.
islink
(
p
):
target
=
os
.
path
.
realpath
(
p
)
self
.
__logger
.
debug
(
"%s is dir %r"
%
(
target
,
os
.
path
.
isdir
(
target
)))
condition
=
os
.
path
.
islink
(
p
)
# and os.path.isdir(target)
else
:
condition
=
(
os
.
path
.
isdir
(
p
))
if
not
condition
:
continue
continue
elif
entry
in
[
"log"
,
"NOFITS"
,
"IGNORE"
]:
elif
entry
in
[
"log"
,
"NOFITS"
,
"IGNORE"
]:
continue
continue
else
:
else
:
d
=
dict
()
d
=
dict
()
d
[
"key"
]
=
relKey
+
'/'
+
entry
d
[
"key"
]
=
relKey
+
'/'
+
entry
d
[
"folder"
]
=
os
.
path
.
is
dir
(
p
)
d
[
"folder"
]
=
not
os
.
path
.
is
file
(
p
)
d
[
"lazy"
]
=
d
[
"folder"
]
d
[
"lazy"
]
=
d
[
"folder"
]
if
entry
.
endswith
(
".fits"
)
:
if
entry
.
endswith
(
".fits"
)
:
size
=
DataBlock
.
convert_size
(
os
.
path
.
getsize
(
p
))
size
=
DataBlock
.
convert_size
(
os
.
path
.
getsize
(
p
))
...
@@ -86,6 +97,7 @@ class DataManagerImpl :
...
@@ -86,6 +97,7 @@ class DataManagerImpl :
except
Exception
as
e
:
except
Exception
as
e
:
result
=
{
"status"
:
False
,
"message"
:
"Problem while looking for entries under '%s'. Error message was '%s'"
%
(
relKey
,
e
)}
result
=
{
"status"
:
False
,
"message"
:
"Problem while looking for entries under '%s'. Error message was '%s'"
%
(
relKey
,
e
)}
self
.
__logger
.
debug
(
"%r"
%
result
)
self
.
__logger
.
debug
(
"%r"
%
result
)
self
.
__logger
.
debug
(
"%r"
%
result
)
self
.
__logger
.
debug
(
"__getEntries_0: exiting"
)
self
.
__logger
.
debug
(
"__getEntries_0: exiting"
)
return
result
return
result
...
...
yafitsv/public/javascript/olqv_utils.js
View file @
2e92f510
...
@@ -116,7 +116,7 @@ function decLabelFormatter (dec0pix, dec1pix, dec0, dec1) {
...
@@ -116,7 +116,7 @@ function decLabelFormatter (dec0pix, dec1pix, dec0, dec1) {
function
summedPixelsSpectrumUnit
(
unit
)
{
function
summedPixelsSpectrumUnit
(
unit
)
{
switch
(
unit
)
{
switch
(
unit
)
{
case
"
Jy/beam
"
:
case
"
Jy/beam
"
:
return
"
Jy
/beam * km/s
"
;
return
"
Jy
"
;
break
;
break
;
case
"
erg/s/cm^2/A/arcsec^2
"
:
case
"
erg/s/cm^2/A/arcsec^2
"
:
...
...
yafitsv/views/olqv_2d.ejs
View file @
2e92f510
...
@@ -179,10 +179,16 @@ th, td {
...
@@ -179,10 +179,16 @@ th, td {
<div
id=
"FITSHDR"
class=
"overlay"
style=
"overflow:scroll"
></div>
<div
id=
"FITSHDR"
class=
"overlay"
style=
"overflow:scroll"
></div>
<
%
include
olqv_infosblock
%
>
<
%
include
olqv_infosblock
%
>
<
%
include
olqv_navbar_external_content
%
>
<
%
include
olqv_navbar_external_content
%
>
<
%
include
olqv_settings
%
>
<
%
include
olqv_customcontrols
%
>
<
%
include
olqv_customcontrols
%
>
<
%
include
olqv_reset
%
>
<
%
include
olqv_reset
%
>
<
%
include
olqv_samp_publisher
%
>
<
%
include
olqv_samp_publisher
%
>
<
%
include
olqv_shapes
%
>
<
%
include
olqv_contours
%
>
<
%
include
olqv_boxes
%
>
<
%
include
olqv_boxes
%
>
<
%
include
olqv_markers
%
>
<
%
include
olqv_keyboardevents
%
>
<div
id=
"fullscreen"
class=
"fullscreen"
>
<div
id=
"fullscreen"
class=
"fullscreen"
>
<div
class=
"sidepanel"
>
<div
class=
"sidepanel"
>
<nav
class=
"navbar navbar-dark bg-dark"
>
<nav
class=
"navbar navbar-dark bg-dark"
>
...
@@ -251,30 +257,23 @@ var _imageLoadFunction_1 = function(image, src) {
...
@@ -251,30 +257,23 @@ var _imageLoadFunction_1 = function(image, src) {
** one image built from the content of a 2D FITS file
** one image built from the content of a 2D FITS file
*/
*/
var
_canvasContext
=
null
;
var
_canvasContext
=
null
;
var
yAFITSContoursViewer
;
var
contoursFactory
;
var
yaFITSContours
GUI
;
var
contoursFactory
GUI
;
var
reset
;
var
reset
;
var
settings
;
var
settings
;
var
boxTool
;
var
boxTool
;
var
keyCodeProcessor
;
var
format
=
function
(
floatValue
)
{
let
result
=
floatValue
;
if
(
typeof
result
===
"
number
"
&&
!
Number
.
isInteger
(
result
)){
result
=
result
.
toExponential
(
4
);
}
return
result
;
};
var
infos_line
=
document
.
getElementById
(
'
infos-line
'
);
var
infos_line
=
document
.
getElementById
(
'
infos-line
'
);
var
infos_block
=
document
.
getElementById
(
'
ModalInfosBlockBody
'
);
var
infos_block
=
document
.
getElementById
(
'
ModalInfosBlockBody
'
);
var
populateInfosBlock
=
function
(
title
,
collection
)
{
//
var populateInfosBlock = function(title, collection) {
infos_block
.
innerHTML
=
"
<b>
"
+
title
+
"
<br><br>
"
;
//
infos_block.innerHTML = "
<
b
>
"
+title+
"
<
br
><
br
>
"
;
for
(
var
k
in
collection
)
{
//
for (var k in collection) {
infos_block
.
innerHTML
+=
k
+
"
:
"
+
format
(
collection
[
k
][
"
value
"
])
+
"
"
+
collection
[
k
][
"
unit
"
]
+
"
<br>
"
;
//
infos_block.innerHTML += k +
"
:
"
+ format(collection[k][
"
value
"
]) +
"
"
+ collection[k][
"
unit
"
] +
"
<
br
>
"
;
}
//
}
}
//
}
function SliceViewer (relFITSFilePath, width, height, RADECRangeInDegrees, FITSHeader, divSlice) {
function SliceViewer (relFITSFilePath, width, height, RADECRangeInDegrees, FITSHeader, divSlice) {
console.log(
"
SliceViewer
:
entering
"
);
console.log(
"
SliceViewer
:
entering
"
);
...
@@ -336,6 +335,9 @@ function SliceViewer (relFITSFilePath, width, height, RADECRangeInDegrees, FITSH
...
@@ -336,6 +335,9 @@ function SliceViewer (relFITSFilePath, width, height, RADECRangeInDegrees, FITSH
let _naxis = parseInt(header[
"
NAXIS
"
]);
let _naxis = parseInt(header[
"
NAXIS
"
]);
let _naxis1 = parseInt(header[
"
NAXIS1
"
]);
let _naxis1 = parseInt(header[
"
NAXIS1
"
]);
let _naxis2 = parseInt(header[
"
NAXIS2
"
]);
let _naxis2 = parseInt(header[
"
NAXIS2
"
]);
if (_naxis > 2) _naxis3 = parseInt(header[
"
NAXIS3
"
]);
if (_naxis > 4) _naxis4 = parseInt(header[
"
NAXIS4
"
]);
let _crpix = [parseFloat(header[
"
CRPIX1
"
]), parseFloat(header[
"
CRPIX2
"
])];
let _crpix = [parseFloat(header[
"
CRPIX1
"
]), parseFloat(header[
"
CRPIX2
"
])];
let _crval = [parseFloat(header[
"
CRVAL1
"
]), parseFloat(header[
"
CRVAL2
"
])];
let _crval = [parseFloat(header[
"
CRVAL1
"
]), parseFloat(header[
"
CRVAL2
"
])];
let _cdelt = [parseFloat(header[
"
CDELT1
"
]), parseFloat(header[
"
CDELT2
"
])];
let _cdelt = [parseFloat(header[
"
CDELT1
"
]), parseFloat(header[
"
CDELT2
"
])];
...
@@ -365,6 +367,10 @@ function SliceViewer (relFITSFilePath, width, height, RADECRangeInDegrees, FITSH
...
@@ -365,6 +367,10 @@ function SliceViewer (relFITSFilePath, width, height, RADECRangeInDegrees, FITSH
return result;
return result;
};
};
this.is3D = function() {
return (_naxis==3 && _naxis3>1) || (_naxis==4 && _naxis3>1 && _naxis4==1);
}
this.getSliceIndex = function () {
this.getSliceIndex = function () {
return _sliceIndex;
return _sliceIndex;
}
}
...
@@ -609,7 +615,7 @@ var _marker_styles_f = function(feature) {
...
@@ -609,7 +615,7 @@ var _marker_styles_f = function(feature) {
let properties = selectedFeature.get(
"
properties
"
);
let properties = selectedFeature.get(
"
properties
"
);
let level = properties[
"
level
"
][
"
value
"
].toExponential(3);
let level = properties[
"
level
"
][
"
value
"
].toExponential(3);
if (
"
measurements
"
in properties) {
if (
"
measurements
"
in properties) {
yAFITSContoursViewer
.
selected
(
selectedFeature
);
contoursFactory
.selected(selectedFeature);
}
}
else {
else {
document.getElementById('loading').style.display=
"
block
"
;
document.getElementById('loading').style.display=
"
block
"
;
...
@@ -624,7 +630,7 @@ var _marker_styles_f = function(feature) {
...
@@ -624,7 +630,7 @@ var _marker_styles_f = function(feature) {
console.log(resp[
"
result
"
]);
console.log(resp[
"
result
"
]);
properties[
"
measurements
"
]=resp[
"
result
"
];
properties[
"
measurements
"
]=resp[
"
result
"
];
selectedFeature.set(
"
properties
"
,properties);
selectedFeature.set(
"
properties
"
,properties);
yAFITSContoursViewer
.
selected
(
selectedFeature
);
contoursFactory
.selected(selectedFeature);
}
}
console.log('measureContour callback : exiting');
console.log('measureContour callback : exiting');
});
});
...
@@ -1115,7 +1121,10 @@ $( document ).ready(function() {
...
@@ -1115,7 +1121,10 @@ $( document ).ready(function() {
sliceViewer
=
new
SliceViewer
(
relFITSFilePath
,
width
,
height
,
RADECRangeInDegrees
,
header
,
"
slice
"
);
sliceViewer
=
new
SliceViewer
(
relFITSFilePath
,
width
,
height
,
RADECRangeInDegrees
,
header
,
"
slice
"
);
sliceViewer
.
display
();
sliceViewer
.
display
();
document
.
addEventListener
(
'
keydown
'
,
sliceViewer
.
processKeyCode
,
false
);
//document.addEventListener('keydown', sliceViewer.processKeyCode, false);
keyCodeProcessor
=
new
KeyCodeProcessor
(
sliceViewer
);
keyCodeProcessor
.
open
();
infosBlock
=
new
InfosBlock
(
sliceViewer
);
infosBlock
=
new
InfosBlock
(
sliceViewer
);
...
@@ -1135,11 +1144,11 @@ $( document ).ready(function() {
...
@@ -1135,11 +1144,11 @@ $( document ).ready(function() {
markerFactory
=
new
MarkerFactory
(
sliceViewer
);
markerFactory
=
new
MarkerFactory
(
sliceViewer
);
customControls
.
addButton
(
markerFactory
.
getButton
());
customControls
.
addButton
(
markerFactory
.
getButton
());
yAFITSContoursViewer
=
new
Contours
Viewer
(
sliceViewer
,
infosBlock
);
contoursFactory
=
new
Contours
Factory
(
sliceViewer
,
infosBlock
);
customControls
.
addButton
(
yAFITSContoursViewer
.
getButton
());
customControls
.
addButton
(
contoursFactory
.
getButton
());
yAFITSContours
GUI
=
new
ContoursGUI
();
contoursFactory
GUI
=
new
Contours
Factory
GUI
();
yAFITSContoursGUI
.
connect
(
yAFITSContoursViewer
,
sliceViewer
);
contoursFactoryGUI
.
connect
(
contoursFactory
,
sliceViewer
);
boxFactory
=
new
BoxFactory
(
sliceViewer
,
infosBlock
);
boxFactory
=
new
BoxFactory
(
sliceViewer
,
infosBlock
);
customControls
.
addButton
(
boxFactory
.
getButton
());
customControls
.
addButton
(
boxFactory
.
getButton
());
...
...
yafitsv/views/olqv_boxes.ejs
View file @
2e92f510
<script>
<script>
class BoxFactory {
class BoxFactory
extends ShapesFactory
{
constructor (sliceViewer, infosBlock) {
constructor (sliceViewer, infosBlock) {
super(sliceViewer, infosBlock);
ShapesFactory.enter(this.constructor.name);
console.log("BoxFactory ctor: entering");
console.log("BoxFactory ctor: entering");
this.source;
this.source;
...
@@ -13,53 +15,8 @@ class BoxFactory {
...
@@ -13,53 +15,8 @@ class BoxFactory {
let target = this.map.getTarget();
let target = this.map.getTarget();
this.jTarget = typeof target === "string" ? $("#" + target) : $(target);
this.jTarget = typeof target === "string" ? $("#" + target) : $(target);
this.lastSelectedBox = null;
this.lastSelectedBox = null;
this.highlightStyle = new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255,255,255,0.7)'
}),
stroke: new ol.style.Stroke({
color: '#3399CC',
width: 3
})
});
this.style = {
'LineString': new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'lightblue',
//lineDash: [2],
width: 2
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.6)'
})
}),
'Polygon': new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'lightblue',
//lineDash: [2],
width: 2
}),
fill: new ol.style.Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
})
};
this.style_f = (feature) => {
return this.style[feature.getGeometry().getType()];
};
this.source = new ol.source.Vector();
this.layer = new ol.layer.Vector({source: this.source, style: this.style_f});
this.map.addLayer(this.layer);
this.layer.setZIndex(12);
this.layer.setZIndex(12);
this.visible = true;
this.overlay = null;
this.container = document.getElementById('popup');
this.content = document.getElementById('popup-content');
this.closer = document.getElementById('popup-closer');
this.lastSelectedContour = null;
this.lastSelectedContour = null;
...
@@ -73,77 +30,46 @@ class BoxFactory {
...
@@ -73,77 +30,46 @@ class BoxFactory {
this.button.onclick = f.bind(this);
this.button.onclick = f.bind(this);
this.isOpened = false;
this.isOpened = false;
this.infosBlock = infosBlock;
/*
/*
** This is our dragbox interaction
** This is our dragbox interaction
*/
*/
this.dragBox = new ol.interaction.DragBox({condition: ol.events.condition.platformModifierKeyOnly});
this.dragBox = new ol.interaction.DragBox({condition: ol.events.condition.platformModifierKeyOnly});
this.dragBox.on('boxend', () => {
this.dragBox.on('boxend', () => {
console.log
("this.dragBox.on('boxend', function() { : entering");
ShapesFactory.enter
("this.dragBox.on('boxend', function() { : entering");
var extent = this.dragBox.getGeometry().getExtent();
var extent = this.dragBox.getGeometry().getExtent();
// The real work when a drag box interaction reach its end is done below ( saynchronously )
// The real work when a drag box interaction reach its end is done below ( saynchronously )
//this.createAndMeasureBox(this.relFITSFilePath, this.sliceIndex, extent[0], extent[2], extent[1], extent[3]);
//this.createAndMeasureBox(this.relFITSFilePath, this.sliceIndex, extent[0], extent[2], extent[1], extent[3]);
let box = this.prepareBox(extent[0], extent[2], extent[1], extent[3]);
let box = this.prepareBox(extent[0], extent[2], extent[1], extent[3]);
this.measure(box);
this.measure(box);
console.log("this.dragBox.on('boxend', function() { : exiting"
);
ShapesFactory.exit(
);
});
});
console.log("BoxFactory ctor: exiting"
);
ShapesFactory.exit(
);
}
}
getButton() {
getButton() {
return this.button;
return this.button;
}
}
highlight(feature) {
console.log("highlight : entering");
if (this.lastSelectedBox !== null) {
this.lastSelectedBox.setStyle(undefined);
}
feature.setStyle(this.highlightStyle);
this.lastSelectedBox = feature;
console.log("highlight : exiting");
}
open() {
open() {
console.log('open: entering'
);
ShapesFactory.enter(this.open.name
);
this.map.addInteraction(this.dragBox);
this.map.addInteraction(this.dragBox);
this.jTarget.css('cursor','nwse-resize');
this.jTarget.css('cursor','nwse-resize');
this.isOpened = true;
this.isOpened = true;
console.log('open: exiting'
);
ShapesFactory.exit(
);
}
}
close() {
close() {
console.log('close: open'
);
ShapesFactory.enter(this.close.name
);
this.map.removeInteraction(this.dragBox);
this.map.removeInteraction(this.dragBox);
this.jTarget.css('cursor','pointer');
this.jTarget.css('cursor','pointer');
this.isOpened = false;
this.isOpened = false;
console.log('close: exiting'
);
ShapesFactory.exit(
);
}
}
hide() {
console.log("hide : entering");
this.layer.setVisible(false);
console.log("hide : exiting");
};
show() {
console.log("show : entering");
this.layer.setVisible(true);
console.log("show : exiting");
};
clear() {
console.log("clear : entering");
if (this.lastSelectedBox) this.lastSelectedBox.setStyle(undefined);
this.lastSelectedBox = null;
this.source.clear();
console.log("clear : exiting");
};
prepareBox(iRA0, iRA1, iDEC0, iDEC1){
prepareBox(iRA0, iRA1, iDEC0, iDEC1){
console.log("createBox: entering"
);
ShapesFactory.enter(this.prepareBox.name
);
document.getElementById('loading').style.display='block';
document.getElementById('loading').style.display='block';
var tl = [iRA0, iDEC1];
var tl = [iRA0, iDEC1];
var tr = [iRA1, iDEC1];
var tr = [iRA1, iDEC1];
...
@@ -157,12 +83,12 @@ class BoxFactory {
...
@@ -157,12 +83,12 @@ class BoxFactory {
let properties = {};
let properties = {};
properties["type"]="box";
properties["type"]="box";
feature.set("properties",properties);
feature.set("properties",properties);
console.log("createBox: exiting"
);
ShapesFactory.exit(
);
return feature;
return feature;
}
}
measure(feature, addFeature=true) {
measure(feature, addFeature=true) {
console.log("measure: entering"
);
ShapesFactory.enter(this.measure.name
);
let properties = feature.get("properties");
let properties = feature.get("properties");
if (properties.hasOwnProperty("type") && properties["type"] === "box") {
if (properties.hasOwnProperty("type") && properties["type"] === "box") {
document.getElementById('loading').style.display="block";
document.getElementById('loading').style.display="block";
...
@@ -180,7 +106,7 @@ class BoxFactory {
...
@@ -180,7 +106,7 @@ class BoxFactory {
'iDEC0': iDEC0,
'iDEC0': iDEC0,
'iDEC1': iDEC1 },
'iDEC1': iDEC1 },
(resp) => {
(resp) => {
console.log
('measure callback: entering');
ShapesFactory.enter
('measure callback: entering');
document.getElementById('loading').style.display="none";
document.getElementById('loading').style.display="none";
if ( resp["status"] == false ){
if ( resp["status"] == false ){
alert ("Something went wrong with the measurements of contour. The message was '" + resp["message"]+"'");
alert ("Something went wrong with the measurements of contour. The message was '" + resp["message"]+"'");
...
@@ -193,23 +119,24 @@ class BoxFactory {
...
@@ -193,23 +119,24 @@ class BoxFactory {
this.selected(feature);
this.selected(feature);
}
}
}
}
console.log('measureBox callback: exiting'
);
ShapesFactory.exit(
);
} );
} );
}
}
else {
else {
console.log("Unable to measure such a feature") ;
console.log("Unable to measure such a feature") ;
}
}
console.log("measure : exiting"
);
ShapesFactory.exit(
);
}
}
selected(
feature
) {
selected(
box
) {
console.log("selected : entering"
);
ShapesFactory.enter(this.selected.name
);
let properties =
feature
.get("properties");
let properties =
box
.get("properties");
let title = "Flux in box : " + properties["measurements"]["sum"]["value"].toExponential(4) + " " + properties["measurements"]["sum"]["unit"];
let title = "Flux in box : " + properties["measurements"]["sum"]["value"].toExponential(4) + " " + properties["measurements"]["sum"]["unit"];