Skip to content

Commit

Permalink
Use lodash to handle camera with no zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHardiman committed Nov 25, 2019
1 parent 6c6f089 commit b6de685
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/ptz.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
module.exports = function(Cam) {

const linerase = require('./utils').linerase
;
const linerase = require('./utils').linerase;
const _get = require('lodash/get');

/**
* Receive cam presets
Expand Down Expand Up @@ -175,12 +175,13 @@ module.exports = function(Cam) {
this._envelopeFooter()
}, function(err, data, xml) {
if (!err) {
// Some cameras have Pan/Tilt but no Zoom
var res = linerase(data).getStatusResponse.PTZStatus;
var status = {
position: {
x: res.position.panTilt.$.x
, y: res.position.panTilt.$.y
, zoom: res.position.zoom.$.x
x: _get(res, 'position.panTilt.$.x', 0)
, y: _get(res, 'position.panTilt.$.y', 0)
, zoom: _get(res, 'position.zoom.$.x', 0)
}
, moveStatus: res.moveStatus
, error: res.error
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"url": "https://github.com/agsh/onvif.git"
},
"dependencies": {
"lodash": "^4.17.15",
"xml2js": "^0.4.19"
},
"keywords": [
Expand Down

0 comments on commit b6de685

Please sign in to comment.