diff --git a/javascript/build/ee_api_js.js b/javascript/build/ee_api_js.js index 75541a6..3a1f5f7 100644 --- a/javascript/build/ee_api_js.js +++ b/javascript/build/ee_api_js.js @@ -1,19 +1,19 @@ (function() {var h,aa=aa||{},k=this,l=function(a){return void 0!==a},ba=function(){},ca=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!= typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==b&&"undefined"==typeof a.call)return"object";return b},n=function(a){return"array"==ca(a)},da=function(a){var b=ca(a);return"array"==b||"object"==b&&"number"==typeof a.length},p=function(a){return"string"==typeof a},ea=function(a){return"number"==typeof a},q=function(a){return"function"==ca(a)},r=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b},fa="closure_uid_"+ (1E9*Math.random()>>>0),ga=0,ia=function(a,b,c){return a.call.apply(a.bind,arguments)},ja=function(a,b,c){if(!a)throw Error();if(2b?1:0};var za=function(a,b){b.unshift(a);x.call(this,wa.apply(null,b));b.shift()};v(za,x);za.prototype.name="AssertionError"; var Aa=function(a,b,c,d){var e="Assertion failed";if(c)var e=e+(": "+c),g=d;else a&&(e+=": "+a,g=b);throw new za(""+e,g||[]);},y=function(a,b,c){a||Aa("",null,b,Array.prototype.slice.call(arguments,2));return a},Ba=function(a,b){throw new za("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));},Ca=function(a,b,c){q(a)||Aa("Expected function but got %s: %s.",[ca(a),a],b,Array.prototype.slice.call(arguments,2))};var z=Array.prototype,Da=z.indexOf?function(a,b,c){y(null!=a.length);return z.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(p(a))return p(b)&&1==b.length?a.indexOf(b,c):-1;for(;cb?null:p(a)?a.charAt(b):a[b]},Ja=function(a,b){var c= Da(a,b),d;if(d=0<=c)y(null!=a.length),z.splice.call(a,c,1);return d},Ka=function(a){return z.concat.apply(z,arguments)},La=function(a,b){for(var c=1;c=arguments.length?z.slice.call(a,b):z.slice.call(a,b,c)},Na=function(a){for(var b={},c=0,d=0;db?e+="000":256>b?e+="00":4096>b&&(e+="0");return Ua[a]= e+b.toString(16)}),'"')};va("area base br col command embed hr img input keygen link meta param source track wbr".split(" "));var A;a:{var Wa=k.navigator;if(Wa){var Xa=Wa.userAgent;if(Xa){A=Xa;break a}}A=""};var Ya=function(){return-1!=A.indexOf("Edge")||-1!=A.indexOf("Trident")||-1!=A.indexOf("MSIE")};var Za=function(){return-1!=A.indexOf("Edge")};var $a=-1!=A.indexOf("Opera")||-1!=A.indexOf("OPR"),B=Ya(),ab=-1!=A.indexOf("Gecko")&&!(-1!=A.toLowerCase().indexOf("webkit")&&!Za())&&!(-1!=A.indexOf("Trident")||-1!=A.indexOf("MSIE"))&&!Za(),bb=-1!=A.toLowerCase().indexOf("webkit")&&!Za(),cb=function(){var a=A;if(ab)return/rv\:([^\);]+)(\)|;)/.exec(a);if(B&&Za())return/Edge\/([\d\.]+)/.exec(a);if(B)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(bb)return/WebKit\/(\S+)/.exec(a)},db=function(){var a=k.document;return a?a.documentMode:void 0}, eb=function(){if($a&&k.opera){var a=k.opera.version;return q(a)?a():a}var a="",b=cb();b&&(a=b?b[1]:"");return B&&!Za()&&(b=db(),b>parseFloat(a))?String(b):a}(),fb={},C=function(a){var b;if(!(b=fb[a])){b=0;for(var c=xa(String(eb)).split("."),d=xa(String(a)).split("."),e=Math.max(c.length,d.length),g=0;0==b&&g=a.keyCode)a.keyCode=-1}catch(b){}};var mc="closure_listenable_"+(1E6*Math.random()|0),nc=0;var oc=function(a,b,c,d,e){this.G=a;this.pa=null;this.src=b;this.type=c;this.fa=!!d;this.ja=e;this.key=++nc;this.N=this.ea=!1},pc=function(a){a.N=!0;a.G=null;a.pa=null;a.src=null;a.ja=null};var qc=function(a){this.src=a;this.k={};this.ca=0};qc.prototype.add=function(a,b,c,d,e){var g=a.toString();a=this.k[g];a||(a=this.k[g]=[],this.ca++);var f=rc(a,b,d,e);-1e.keyCode||void 0!=e.returnValue)){a:{var g=!1;if(0==e.keyCode)try{e.keyCode=-1;break a}catch(f){g= !0}if(g||void 0==e.returnValue)e.returnValue=!0}e=[];for(g=c.currentTarget;g;g=g.parentNode)e.push(g);for(var g=a.type,m=e.length-1;!c.M&&0<=m;m--){c.currentTarget=e[m];var K=Fc(e[m],g,!0,c),d=d&&K}for(m=0;!c.M&&m>>0),xc=function(a){y(a,"Listener can not be null.");if(q(a))return a;y(a.handleEvent,"An object listener must have handleEvent method."); a[Gc]||(a[Gc]=function(b){return a.handleEvent(b)});return a[Gc]};var Hc=function(){gc.call(this);this.r=new qc(this);this.wb=this;this.Sa=null};v(Hc,gc);Hc.prototype[mc]=!0;h=Hc.prototype;h.addEventListener=function(a,b,c,d){wc(this,a,b,c,d)};h.removeEventListener=function(a,b,c,d){Cc(this,a,b,c,d)}; h.dispatchEvent=function(a){Ic(this);var b,c=this.Sa;if(c){b=[];for(var d=1;c;c=c.Sa)b.push(c),y(1E3>++d,"infinite loop")}c=this.wb;d=a.type||a;if(p(a))a=new hc(a,c);else if(a instanceof hc)a.target=a.target||c;else{var e=a;a=new hc(d,c);ua(a,e)}var e=!0,g;if(b)for(var f=b.length-1;!a.M&&0<=f;f--)g=a.currentTarget=b[f],e=Jc(g,d,!0,a)&&e;a.M||(g=a.currentTarget=c,e=Jc(g,d,!0,a)&&e,a.M||(e=Jc(g,d,!1,a)&&e));if(b)for(f=0;!a.M&&f2*this.j&&Nc(this),!0):!1};var Nc=function(a){if(a.j!=a.i.length){for(var b=0,c=0;b=c.length)throw Kc;var f=c[b++];return a?f:d[f]}};return f};var Oc=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var Pc=function(a){if("function"==typeof a.v)return a.v();if(p(a))return a.split("");if(da(a)){for(var b=[],c=a.length,d=0;d=Yc(this).value)for(q(b)&&(b=b()),a=new Rc(a,String(b),this.ac),c&&(a.cb=c),c="log:"+a.$b,k.console&&(k.console.timeStamp?k.console.timeStamp(c):k.console.markTimeline&&k.console.markTimeline(c)),k.msWriteProfilerMark&&k.msWriteProfilerMark(c),c=this;c;){b=c;var d=a;if(b.fb)for(var e=0,g=void 0;g=b.fb[e];e++)g(d);c=c.getParent()}}; -var Zc={},$c=null,ad=function(a){$c||($c=new Tc(""),Zc[""]=$c,$c.pb(Wc));var b;if(!(b=Zc[a])){b=new Tc(a);var c=a.lastIndexOf("."),d=a.substr(c+1),c=ad(a.substr(0,c));c.Ob()[d]=b;b.e=c;Zc[a]=b}return b};var bd=function(a,b){a&&a.log(Xc,b,void 0)};var cd=function(a,b,c){if(q(a))c&&(a=t(a,c));else if(a&&"function"==typeof a.handleEvent)a=t(a.handleEvent,a);else throw Error("Invalid listener argument");return 21474836472*this.j&&Nc(this),!0):!1};var Nc=function(a){if(a.j!=a.h.length){for(var b=0,c=0;b=d.h.length)throw Kc;var e=d.h[b++];return a?e:d.s[e]};return e};var Oc=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var Pc=function(a){if("function"==typeof a.v)return a.v();if(p(a))return a.split("");if(da(a)){for(var b=[],c=a.length,d=0;d=Yc(this).value)for(q(b)&&(b=b()),a=new Rc(a,String(b),this.$b),c&&(a.cb=c),c="log:"+a.Zb,k.console&&(k.console.timeStamp?k.console.timeStamp(c):k.console.markTimeline&&k.console.markTimeline(c)),k.msWriteProfilerMark&&k.msWriteProfilerMark(c),c=this;c;){b=c;var d=a;if(b.fb)for(var e=0,g=void 0;g=b.fb[e];e++)g(d);c=c.getParent()}}; +var Zc={},$c=null,ad=function(a){$c||($c=new Tc(""),Zc[""]=$c,$c.pb(Wc));var b;if(!(b=Zc[a])){b=new Tc(a);var c=a.lastIndexOf("."),d=a.substr(c+1),c=ad(a.substr(0,c));c.Nb()[d]=b;b.e=c;Zc[a]=b}return b};var bd=function(a,b){a&&a.log(Xc,b,void 0)};var cd=function(a,b,c){if(q(a))c&&(a=t(a,c));else if(a&&"function"==typeof a.handleEvent)a=t(a.handleEvent,a);else throw Error("Invalid listener argument");return 2147483647b&&(b+=e);return[Dd,"map",a.mapid,d,b,c].join("/")+"?token="+a.token});var Nd=function(a,b){a=w(a);return F("/value",G(a),b)};u("ee.data.getValue",Nd);var Od=function(a,b){a=w(a);n(a.size)&&(a.size=a.size.join("x"));var c=G(a).add("getid","1");return F("/thumb",c,b)};u("ee.data.getThumbId",Od);var Pd=function(a){return Dd+"/api/thumb?thumbid="+a.thumbid+"&token="+a.token};u("ee.data.makeThumbUrl",Pd); var Qd=function(a,b){a=w(a);return F("/download",G(a),b)};u("ee.data.getDownloadId",Qd);var Rd=function(a){return Dd+"/api/download?docid="+a.docid+"&token="+a.token};u("ee.data.makeDownloadUrl",Rd);var Sd=function(a,b){a=w(a);return F("/table",G(a),b)};u("ee.data.getTableDownloadId",Sd);var Td=function(a){return Dd+"/api/table?docid="+a.docid+"&token="+a.token};u("ee.data.makeTableDownloadUrl",Td); u("ee.data.createAsset",function(a,b,c,d){a={value:a};void 0!==b&&(a.id=b);a.force=c||!1;return F("/create",G(a),d)});u("ee.data.createFolder",function(a,b,c){return F("/createfolder",G({id:a,force:b||!1}),c)});u("ee.data.newTaskId",function(a,b){var c={};ea(a)&&(c.count=a);return F("/newtaskid",G(c),b)});u("ee.data.getTaskStatus",function(a,b){if(p(a))a=[a];else if(!n(a))throw Error("Invalid taskId: expected a string or an array of strings.");return F("/taskstatus?q="+a.join(),null,b,"GET")}); u("ee.data.getTaskList",function(a){return F("/tasklist",null,a,"GET")});u("ee.data.cancelTask",function(a,b){return Ud(a,"CANCEL",b)});var Ud=function(a,b,c){if(p(a))a=[a];else if(!n(a))throw Error("Invalid taskId: expected a string or an array of strings.");var d;a:{for(d in Jd)if(Jd[d]==b){d=!0;break a}d=!1}if(!d)throw Error("Invalid action: "+b);return F("/updatetask",G({id:a,action:b}),c,"POST")};u("ee.data.updateTask",Ud); -u("ee.data.prepareValue",function(a,b,c){b=w(b);b.tid=a;return F("/prepare",G(b),c)});u("ee.data.startProcessing",function(a,b,c){b=w(b);b.id=a;return F("/processingrequest",G(b),c)});u("ee.data.startIngestion",function(a,b,c){a={id:a,request:(new Qa(void 0)).h(b)};return F("/ingestionrequest",G(a),c)});u("ee.data.getAssetRoots",function(a){return F("/buckets",null,a,"GET")}); +u("ee.data.prepareValue",function(a,b,c){b=w(b);b.tid=a;return F("/prepare",G(b),c)});u("ee.data.startProcessing",function(a,b,c){b=w(b);b.id=a;return F("/processingrequest",G(b),c)});u("ee.data.startIngestion",function(a,b,c){a={id:a,request:(new Qa(void 0)).i(b)};return F("/ingestionrequest",G(a),c)});u("ee.data.getAssetRoots",function(a){return F("/buckets",null,a,"GET")}); var F=function(a,b,c,d){Kd();d=d||"POST";var e={"Content-Type":"application/x-www-form-urlencoded"};null!=Fd&&(e.Authorization=Fd);null!=Ed&&("GET"==d?(a+=-1!=a.indexOf("?")?"&":"?",a+="xsrfToken="+Ed):(b||(b=new zd),b.add("xsrfToken",Ed)));var g=function(a,b,c,d){var e,g,f;b=b?b.replace(/;.*/,""):"application/json";if("application/json"==b||"text/json"==b)try{e=Pa(c),g=e.data}catch(m){f="Invalid JSON: "+c}else f="Response was unexpectedly not JSON, but "+b;if(r(e))"error"in e&&"message"in e.error? f=e.error.message:"data"in e||(f="Malformed response: "+c);else if(200>a||300<=a)f="Server returned HTTP code: "+a;if(d)return d(g,f),null;if(!f)return g;throw Error(f);};a=Cd+a;b=b?b.toString():"";if(c)return rd(a,function(a){a=a.target;var b=a.getStatus(),d=a.getResponseHeader("Content-Type"),e;try{e=a.a?a.a.responseText:""}catch(f){bd(a.o,"Can not get responseText: "+f.message),e=""}return g(b,d,e,c)},d,b,e),null;var f=D();f.open(d,a,!1);la(e,function(a,b){f.setRequestHeader(b,a)});f.send(b);var m; -try{m=f.getResponseHeader("Content-Type")}catch(K){m="application/json"}return g(f.status,m,f.responseText,null)},Ld=function(a,b){var c={client_id:Gd,immediate:!0,scope:Hd.join(" ")},d=function(c){c.access_token?(Fd=c.token_type+" "+c.access_token,setTimeout(Ld,1E3*c.expires_in/2),a&&a()):b&&b(c.error||"Unknown error.")},e=k.gapi.auth.authorize;e(c,function(a){"immediate_failed"==a.error?(c.immediate=!1,e(c,d)):d(a)})},G=function(a){var b=new zd,c;for(c in a)b.set(c,a[c]);return b};var Vd=function(){};var Wd=function(){this.t=-1};var Xd=function(){this.t=-1;this.t=64;this.g=Array(4);this.zb=Array(this.t);this.ta=this.R=0;this.reset()};v(Xd,Wd);Xd.prototype.reset=function(){this.g[0]=1732584193;this.g[1]=4023233417;this.g[2]=2562383102;this.g[3]=271733878;this.ta=this.R=0}; +try{m=f.getResponseHeader("Content-Type")}catch(K){m="application/json"}return g(f.status,m,f.responseText,null)},Ld=function(a,b){var c={client_id:Gd,immediate:!0,scope:Hd.join(" ")},d=function(c){c.access_token?(Fd=c.token_type+" "+c.access_token,setTimeout(Ld,1E3*c.expires_in/2),a&&a()):b&&b(c.error||"Unknown error.")},e=k.gapi.auth.authorize;e(c,function(a){"immediate_failed"==a.error?(c.immediate=!1,e(c,d)):d(a)})},G=function(a){var b=new zd,c;for(c in a)b.set(c,a[c]);return b};var Vd=function(){};var Wd=function(){this.t=-1};var Xd=function(){this.t=-1;this.t=64;this.g=Array(4);this.yb=Array(this.t);this.ta=this.R=0;this.reset()};v(Xd,Wd);Xd.prototype.reset=function(){this.g[0]=1732584193;this.g[1]=4023233417;this.g[2]=2562383102;this.g[3]=271733878;this.ta=this.R=0}; var Yd=function(a,b,c){c||(c=0);var d=Array(16);if(p(b))for(var e=0;16>e;++e)d[e]=b.charCodeAt(c++)|b.charCodeAt(c++)<<8|b.charCodeAt(c++)<<16|b.charCodeAt(c++)<<24;else for(e=0;16>e;++e)d[e]=b[c++]|b[c++]<<8|b[c++]<<16|b[c++]<<24;b=a.g[0];c=a.g[1];var e=a.g[2],g=a.g[3],f=0,f=b+(g^c&(e^g))+d[0]+3614090360&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[1]+3905402710&4294967295;g=b+(f<<12&4294967295|f>>>20);f=e+(c^g&(b^c))+d[2]+606105819&4294967295;e=g+(f<<17&4294967295|f>>>15);f=c+(b^e& (g^b))+d[3]+3250441966&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(g^c&(e^g))+d[4]+4118548399&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[5]+1200080426&4294967295;g=b+(f<<12&4294967295|f>>>20);f=e+(c^g&(b^c))+d[6]+2821735955&4294967295;e=g+(f<<17&4294967295|f>>>15);f=c+(b^e&(g^b))+d[7]+4249261313&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(g^c&(e^g))+d[8]+1770035416&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[9]+2336552879&4294967295;g=b+(f<<12&4294967295|f>>>20);f= e+(c^g&(b^c))+d[10]+4294925233&4294967295;e=g+(f<<17&4294967295|f>>>15);f=c+(b^e&(g^b))+d[11]+2304563134&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(g^c&(e^g))+d[12]+1804603682&4294967295;b=c+(f<<7&4294967295|f>>>25);f=g+(e^b&(c^e))+d[13]+4254626195&4294967295;g=b+(f<<12&4294967295|f>>>20);f=e+(c^g&(b^c))+d[14]+2792965006&4294967295;e=g+(f<<17&4294967295|f>>>15);f=c+(b^e&(g^b))+d[15]+1236535329&4294967295;c=e+(f<<22&4294967295|f>>>10);f=b+(e^g&(c^e))+d[1]+4129170786&4294967295;b=c+(f<<5&4294967295| @@ -84,18 +84,18 @@ b^c)+d[7]+4139469664&4294967295;e=g+(f<<16&4294967295|f>>>16);f=c+(e^g^b)+d[10]+ g=b+(f<<11&4294967295|f>>>21);f=e+(g^b^c)+d[15]+530742520&4294967295;e=g+(f<<16&4294967295|f>>>16);f=c+(e^g^b)+d[2]+3299628645&4294967295;c=e+(f<<23&4294967295|f>>>9);f=b+(e^(c|~g))+d[0]+4096336452&4294967295;b=c+(f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[7]+1126891415&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[14]+2878612391&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[5]+4237533241&4294967295;c=e+(f<<21&4294967295|f>>>11);f=b+(e^(c|~g))+d[12]+1700485571&4294967295;b=c+ (f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[3]+2399980690&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[10]+4293915773&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[1]+2240044497&4294967295;c=e+(f<<21&4294967295|f>>>11);f=b+(e^(c|~g))+d[8]+1873313359&4294967295;b=c+(f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[15]+4264355552&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[6]+2734768916&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[13]+1309151649&4294967295; c=e+(f<<21&4294967295|f>>>11);f=b+(e^(c|~g))+d[4]+4149444226&4294967295;b=c+(f<<6&4294967295|f>>>26);f=g+(c^(b|~e))+d[11]+3174756917&4294967295;g=b+(f<<10&4294967295|f>>>22);f=e+(b^(g|~c))+d[2]+718787259&4294967295;e=g+(f<<15&4294967295|f>>>17);f=c+(g^(e|~b))+d[9]+3951481745&4294967295;a.g[0]=a.g[0]+b&4294967295;a.g[1]=a.g[1]+(e+(f<<21&4294967295|f>>>11))&4294967295;a.g[2]=a.g[2]+e&4294967295;a.g[3]=a.g[3]+g&4294967295}; -Xd.prototype.update=function(a,b){l(b)||(b=a.length);for(var c=b-this.t,d=this.zb,e=this.R,g=0;ga.R?a.t:2*a.t)-a.R);b[0]=128;for(var c=1;cc;++c)for(var e=0;32>e;e+=8)b[d++]=a.g[c]>>>e&255;return b};var ae=function(a){this.da="__ee_hash__";this.Pa=!1!==a;this.O=[];this.J={};this.Wa=[]};u("ee.Serializer",ae);var be=new Qa,Zd=new Xd,de=function(a,b){return ce(new ae(l(b)?b:!0),a)};u("ee.Serializer.encode",de);var fe=function(a){return be.h(de(a))};u("ee.Serializer.toJSON",fe);var ge=function(a){a=ce(new ae(!1),a);return"JSON"in k?k.JSON.stringify(a,null," "):be.h(a)};u("ee.Serializer.toReadableJSON",ge); +Xd.prototype.update=function(a,b){l(b)||(b=a.length);for(var c=b-this.t,d=this.yb,e=this.R,g=0;ga.R?a.t:2*a.t)-a.R);b[0]=128;for(var c=1;cc;++c)for(var e=0;32>e;e+=8)b[d++]=a.g[c]>>>e&255;return b};var ae=function(a){this.da="__ee_hash__";this.Pa=!1!==a;this.O=[];this.J={};this.Wa=[]};u("ee.Serializer",ae);var be=new Qa,Zd=new Xd,de=function(a,b){return ce(new ae(l(b)?b:!0),a)};u("ee.Serializer.encode",de);var fe=function(a){return be.i(de(a))};u("ee.Serializer.toJSON",fe);var ge=function(a){a=ce(new ae(!1),a);return"JSON"in k?k.JSON.stringify(a,null," "):be.i(a)};u("ee.Serializer.toReadableJSON",ge); var ce=function(a,b){var c=a.ga(b);a.Pa&&(c=r(c)&&"ValueRef"==c.type&&1==a.O.length?a.O[0][1]:{type:"CompoundValue",scope:a.O,value:c},a.O=[],Ea(a.Wa,t(function(a){delete a[this.da]},a)),a.Wa=[],a.J={});return c}; ae.prototype.ga=function(a){if(!l(a))throw Error("Can't encode an undefined value.");var b,c=r(a)?a[this.da]:null;if(this.Pa&&null!=c&&this.J[c])return{type:"ValueRef",value:this.J[c]};if(null===a||"boolean"==typeof a||ea(a)||p(a))return a;if(r(a)&&"function"==typeof a.getFullYear)return{type:"Invocation",functionName:"Date",arguments:{value:Math.floor(a.getTime())}};if(a instanceof Vd){if(b=a.encode(t(this.ga,this)),!(n(b)||r(b)&&"ArgumentRef"!=b.type))return b}else if(n(a))b=Fa(a,function(a){return this.ga(a)}, -this);else if(r(a)&&!q(a))b=oa(a,function(a){if(!q(a))return this.ga(a)},this),ra(b,this.da),b={type:"Dictionary",value:b};else throw Error("Can't encode object: "+a);if(this.Pa){Zd.reset();Zd.update(be.h(b));var c=$d().toString(),d;this.J[c]?d=this.J[c]:(d=String(this.O.length),this.O.push([d,b]),this.J[c]=d);a[this.da]=c;this.Wa.push(a);return{type:"ValueRef",value:d}}return b};var H=function(a,b,c){if(!(this instanceof H))return I(H,arguments);if(c&&(a||b))throw Error('When "opt_varName" is specified, "func" and "args" must be null.');if(a&&!b)throw Error('When "func" is specified, "args" must not be null.');this.b=a;this.c=b;this.f=c||null};v(H,Vd);u("ee.ComputedObject",H);H.prototype.m=function(a){return Nd({json:this.h()},a)};u("ee.ComputedObject.prototype.getInfo",H.prototype.m); -H.prototype.encode=function(a){if(null===this.b&&null===this.c)return{type:"ArgumentRef",value:this.f};var b={},c;for(c in this.c)l(this.c[c])&&(b[c]=a(this.c[c]));b={type:"Invocation",arguments:b};a=a(this.b);b[p(a)?"functionName":"function"]=a;return b};H.prototype.h=function(){return fe(this)};u("ee.ComputedObject.prototype.serialize",H.prototype.h);H.prototype.toString=function(){return"ee."+this.name()+"("+ge(this)+")"};u("ee.ComputedObject.prototype.toString",H.prototype.toString); +this);else if(r(a)&&!q(a))b=oa(a,function(a){if(!q(a))return this.ga(a)},this),ra(b,this.da),b={type:"Dictionary",value:b};else throw Error("Can't encode object: "+a);if(this.Pa){Zd.reset();Zd.update(be.i(b));var c=$d().toString(),d;this.J[c]?d=this.J[c]:(d=String(this.O.length),this.O.push([d,b]),this.J[c]=d);a[this.da]=c;this.Wa.push(a);return{type:"ValueRef",value:d}}return b};var H=function(a,b,c){if(!(this instanceof H))return I(H,arguments);if(c&&(a||b))throw Error('When "opt_varName" is specified, "func" and "args" must be null.');if(a&&!b)throw Error('When "func" is specified, "args" must not be null.');this.b=a;this.c=b;this.f=c||null};v(H,Vd);u("ee.ComputedObject",H);H.prototype.m=function(a){return Nd({json:this.i()},a)};u("ee.ComputedObject.prototype.getInfo",H.prototype.m); +H.prototype.encode=function(a){if(null===this.b&&null===this.c)return{type:"ArgumentRef",value:this.f};var b={},c;for(c in this.c)l(this.c[c])&&(b[c]=a(this.c[c]));b={type:"Invocation",arguments:b};a=a(this.b);b[p(a)?"functionName":"function"]=a;return b};H.prototype.i=function(){return fe(this)};u("ee.ComputedObject.prototype.serialize",H.prototype.i);H.prototype.toString=function(){return"ee."+this.name()+"("+ge(this)+")"};u("ee.ComputedObject.prototype.toString",H.prototype.toString); H.prototype.name=function(){return"ComputedObject"};var he=function(a,b){if(b instanceof a.constructor)return b;var c=function(){};c.prototype=a.constructor.prototype;c=new c;c.b=b.b;c.c=b.c;c.f=b.f;return c},I=function(a,b){function c(){return a.apply(this,b)}c.prototype=a.prototype;return new c};var ie={},je=function(a){return a.prototype instanceof H?a.prototype.name.call(null):a==Number?"Number":a==String?"String":a==Array?"Array":a==Date?"Date":"Object"},ke=function(a,b){if(b==a)return!0;switch(a){case "Element":return"Element"==b||"Image"==b||"Feature"==b||"Collection"==b||"ImageCollection"==b||"FeatureCollection"==b;case "FeatureCollection":case "Collection":return"Collection"==b||"ImageCollection"==b||"FeatureCollection"==b;case "Object":return!0;default:return!1}},le=function(a){return ea(a)|| a instanceof H&&"Number"==a.name()},me=function(a){return p(a)||a instanceof H&&"String"==a.name()},ne=function(a){return r(a)&&!q(a)?(a=Object.getPrototypeOf(a),null!==a&&null===Object.getPrototypeOf(a)):!1};var J=function(){if(!(this instanceof J))return new J};v(J,Vd);u("ee.Function",J);var oe=function(a){return a};J.prototype.call=function(a){return this.apply(pe(this,Array.prototype.slice.call(arguments,0)))};u("ee.Function.prototype.call",J.prototype.call);J.prototype.apply=function(a){a=new H(this,qe(this,a));return oe(a,this.n().returns)};u("ee.Function.prototype.apply",J.prototype.apply); var re=function(a,b,c){var d=l(b),e=a.n(),g=!1;if(1==c.length&&ne(c[0])){var f=e.args;d&&(f=f.slice(1));f.length&&(g=!((1==f.length||f[1].optional)&&"Dictionary"==f[0].type))}if(g){if(c=w(c[0]),d){d=e.args[0].name;if(d in c)throw Error("Named args for "+e.name+" can't contain keyword "+d);c[d]=b}}else c=pe(a,d?[b].concat(c):c);return a.apply(c)},qe=function(a,b){for(var c=a.n().args,d={},e={},g=0;g/,"");for(var c=0;c/,"");return new L(b,a)}),a&&a())};a?F("/algorithms",null,c,"GET"):c(F("/algorithms",null,void 0,"GET"))}},N=function(a,b,c,d){ve();var e=d||"";la(ma,function(d,f){var m=f.split(".");if(2==m.length&&m[0]==b){var m=e+m[1],K=d.n();ue[f]=!0;var ha=!1; if(K.args.length)var U=K.args[0].type,ha="Object"!=U&&ke(U,c);U=ha?a.prototype:a;m in U||(U[m]=function(a){return re(d,ha?this:void 0,Array.prototype.slice.call(arguments,0))},U[m].toString=t(d.toString,d,m,ha),U[m].signature=K)}})},O=function(a){var b=function(a){for(var b in a)q(a[b])&&a[b].signature&&delete a[b]};b(a);b(a.prototype)};var P=function(a,b,c){H.call(this,a,b,c);ze()};v(P,H);u("ee.Element",P);var Ae=!1,ze=function(){Ae||(N(P,"Element","Element"),Ae=!0)};P.prototype.name=function(){return"Element"}; @@ -105,48 +105,49 @@ var Ce=!1,Be=function(){Ce||(N(Q,"Filter","Filter"),Ce=!0)},De={equals:"equals", var Ee=function(a,b,c){b=b.toLowerCase();var d=!1;0==b.lastIndexOf("not_",0)&&(d=!0,b=b.substring(4));if(!(b in De))throw Error("Unknown filtering operator: "+b);a=M("Filter."+De[b],a,c);return d?a.C():a};Q.metadata=Ee;var Fe=function(a,b){return M("Filter.equals",a,b)};Q.eq=Fe;var Ge=function(a,b){return Fe(a,b).C()};Q.neq=Ge;var He=function(a,b){return M("Filter.lessThan",a,b)};Q.lt=He;var Ie=function(a,b){return He(a,b).C()};Q.gte=Ie;var Je=function(a,b){return M("Filter.greaterThan",a,b)}; Q.gt=Je;var Ke=function(a,b){return Je(a,b).C()};Q.lte=Ke;var Le=function(a,b){return M("Filter.stringContains",a,b)};Q.contains=Le;var Me=function(a,b){return Le(a,b).C()};Q.not_contains=Me;var Ne=function(a,b){return M("Filter.stringStartsWith",a,b)};Q.starts_with=Ne;var Oe=function(a,b){return Ne(a,b).C()};Q.not_starts_with=Oe;var Pe=function(a,b){return M("Filter.stringEndsWith",a,b)};Q.ends_with=Pe;var Qe=function(a,b){return Pe(a,b).C()};Q.not_ends_with=Qe; var Re=function(a){return M("Filter.and",Array.prototype.slice.call(arguments))};Q.and=Re;Q.or=function(a){return M("Filter.or",Array.prototype.slice.call(arguments))};var Se=function(a,b){var c=M("DateRange",a,b);return te("Filter.dateRangeContains",{leftValue:c,rightField:"system:time_start"})};Q.date=Se;var Te=function(a,b,c,d){return te("Filter.listContains",{leftField:c,rightValue:d,rightField:a,leftValue:b})};Q.inList=Te; -var Ue=function(a,b){return te("Filter.intersects",{leftField:".all",rightValue:M("Feature",a),maxError:b})};Q.bounds=Ue;Q.prototype.Hb=function(a){return R(this,Fe.apply(null,[].slice.call(arguments)))};Q.prototype.eq=Q.prototype.Hb;Q.prototype.bc=function(a){return R(this,Ge.apply(null,[].slice.call(arguments)))};Q.prototype.neq=Q.prototype.bc;Q.prototype.Yb=function(a){return R(this,He.apply(null,[].slice.call(arguments)))};Q.prototype.lt=Q.prototype.Yb; -Q.prototype.Rb=function(a){return R(this,Ie.apply(null,[].slice.call(arguments)))};Q.prototype.gte=Q.prototype.Rb;Q.prototype.Qb=function(a){return R(this,Je.apply(null,[].slice.call(arguments)))};Q.prototype.gt=Q.prototype.Qb;Q.prototype.Zb=function(a){return R(this,Ke.apply(null,[].slice.call(arguments)))};Q.prototype.lte=Q.prototype.Zb;Q.prototype.contains=function(a){return R(this,Le.apply(null,[].slice.call(arguments)))};Q.prototype.contains=Q.prototype.contains; -Q.prototype.cc=function(a){return R(this,Me.apply(null,[].slice.call(arguments)))};Q.prototype.not_contains=Q.prototype.cc;Q.prototype.jc=function(a){return R(this,Ne.apply(null,[].slice.call(arguments)))};Q.prototype.starts_with=Q.prototype.jc;Q.prototype.ec=function(a){return R(this,Oe.apply(null,[].slice.call(arguments)))};Q.prototype.not_starts_with=Q.prototype.ec;Q.prototype.Gb=function(a){return R(this,Pe.apply(null,[].slice.call(arguments)))};Q.prototype.ends_with=Q.prototype.Gb; -Q.prototype.dc=function(a){return R(this,Qe.apply(null,[].slice.call(arguments)))};Q.prototype.not_ends_with=Q.prototype.dc;Q.prototype.yb=function(a){return R(this,Re.apply(null,[].slice.call(arguments)))};Q.prototype.and=Q.prototype.yb;Q.prototype.Eb=function(a){return R(this,Se.apply(null,[].slice.call(arguments)))};Q.prototype.date=Q.prototype.Eb;Q.prototype.Tb=function(a){return R(this,Te.apply(null,[].slice.call(arguments)))};Q.prototype.inList=Q.prototype.Tb; -Q.prototype.bounds=function(a){return R(this,Ue.apply(null,[].slice.call(arguments)))};Q.prototype.bounds=Q.prototype.bounds;Q.prototype.name=function(){return"Filter"};var S=function(a,b,c){P.call(this,a,b,c);Ve()};v(S,P);u("ee.Collection",S);var We=!1,Ve=function(){We||(N(S,"Collection","Collection"),N(S,"AggregateFeatureCollection","Collection","aggregate_"),We=!0)};S.prototype.filter=function(a){if(!a)throw Error("Empty filters.");return he(this,M("Collection.filter",this,a))};u("ee.Collection.prototype.filter",S.prototype.filter);S.prototype.Mb=function(a,b,c){return this.filter(Ee(a,b,c))};u("ee.Collection.prototype.filterMetadata",S.prototype.Mb); -S.prototype.Kb=function(a){return this.filter(Ue(a))};u("ee.Collection.prototype.filterBounds",S.prototype.Kb);S.prototype.Lb=function(a,b){return this.filter(Se(a,b))};u("ee.Collection.prototype.filterDate",S.prototype.Lb);S.prototype.limit=function(a,b,c){return he(this,M("Collection.limit",this,a,b,c))};u("ee.Collection.prototype.limit",S.prototype.limit);S.prototype.sort=function(a,b){return he(this,M("Collection.limit",this,void 0,a,b))};u("ee.Collection.prototype.sort",S.prototype.sort); -S.prototype.name=function(){return"Collection"};S.prototype.elementType=function(){return P};S.prototype.map=function(a){var b=this.elementType();return he(this,M("Collection.map",this,function(c){return a(new b(c))}))};u("ee.Collection.prototype.map",S.prototype.map);S.prototype.Vb=function(a,b){var c=l(b)?b:null,d=this.elementType();return M("Collection.iterate",this,function(b,c){return a(new d(b),c)},c)};u("ee.Collection.prototype.iterate",S.prototype.Vb);var Xe=function(a){if(!(this instanceof Xe))return I(Xe,arguments);if(a instanceof Xe)return a;Ye();if(ea(a))H.call(this,null,null),this.Ra=a;else if(a instanceof H)H.call(this,a.b,a.c,a.f),this.Ra=null;else throw Error("Invalid argument specified for ee.Number(): "+a);};v(Xe,H);u("ee.Number",Xe);var Ze=!1,Ye=function(){Ze||(N(Xe,"Number","Number"),Ze=!0)};Xe.prototype.encode=function(a){return ea(this.Ra)?this.Ra:Xe.p.encode.call(this,a)};Xe.prototype.name=function(){return"Number"};var T=function(a){if(!(this instanceof T))return I(T,arguments);if(a instanceof T)return a;$e();if(p(a))H.call(this,null,null),this.Va=a;else if(a instanceof H)this.Va=null,a.b&&"String"==a.b.n().returns?H.call(this,a.b,a.c,a.f):H.call(this,new L("String"),{input:a},null);else throw Error("Invalid argument specified for ee.String(): "+a);};v(T,H);u("ee.String",T);var af=!1,$e=function(){af||(N(T,"String","String"),af=!0)}; -T.prototype.encode=function(a){return p(this.Va)?this.Va:T.p.encode.call(this,a)};T.prototype.name=function(){return"String"};var bf=function(a,b){if(!(this instanceof bf))return I(bf,arguments);for(var c=[],d=a.args,e=0;eb||4b||4/,"");c[e]=!0}var g=k.ee,f;for(f in b)f in c&&!(f in g)&&(g[f]=Wf(f),Uf.push(f),a[f]?(g[f].signature=a[f],g[f].signature.isConstructor=!0,ue[f]=!0):g[f].signature={});ie=g;Xf()}catch(m){Tf(m);return}Pf="ready";for(Qf=[];0/,"");c[e]=!0}var g=k.ee,f;for(f in b)f in c&&!(f in g)&&(g[f]=Wf(f),Uf.push(f),a[f]?(g[f].signature=a[f],g[f].signature.isConstructor=!0,ue[f]=!0):g[f].signature={});ie=g;Xf()}catch(m){Tf(m);return}Pf="ready";for(Qf=[];0= keys.length) { - throw goog.iter.StopIteration; - } - var key = keys[i++]; - return opt_keys ? key : map[key]; + if (version != selfObj.version_) { + throw Error("The map has changed since the iterator was created"); } + if (i >= selfObj.keys_.length) { + throw goog.iter.StopIteration; + } + var key = selfObj.keys_[i++]; + return opt_keys ? key : selfObj.map_[key]; }; return newIter; }; @@ -9366,8 +9399,8 @@ ee.Geometry.isValidGeometry_ = function(geometry) { } return !0; } - var nesting = ee.Geometry.isValidCoordinates_(geometry.coordinates); - return "Point" == type && 1 == nesting || "MultiPoint" == type && 2 == nesting || "LineString" == type && 2 == nesting || "LinearRing" == type && 2 == nesting || "MultiLineString" == type && 3 == nesting || "Polygon" == type && 3 == nesting || "MultiPolygon" == type && 4 == nesting; + var coords = geometry.coordinates, nesting = ee.Geometry.isValidCoordinates_(coords); + return "Point" == type && 1 == nesting || "MultiPoint" == type && (2 == nesting || 0 == coords.length) || "LineString" == type && 2 == nesting || "LinearRing" == type && 2 == nesting || "MultiLineString" == type && (3 == nesting || 0 == coords.length) || "Polygon" == type && 3 == nesting || "MultiPolygon" == type && (4 == nesting || 0 == coords.length); }; ee.Geometry.isValidCoordinates_ = function(shape) { if (!goog.isArray(shape)) { @@ -9414,6 +9447,7 @@ ee.Geometry.makeGeometry_ = function(geometry, nesting, opt_coordinates) { if (ee.Geometry.isValidCoordinates_(geometry) != nesting) { throw Error("Invalid geometry"); } + 1 == geometry.length && 0 == geometry[0].length && (geometry = []); return geometry; }; ee.Geometry.createInstance_ = function(klass, args) { @@ -9641,12 +9675,16 @@ ee.Feature.prototype.name = function() { return "Feature"; }; ee.List = function(list) { - if (!(this instanceof ee.List)) { + if (this instanceof ee.List) { + if (1 < arguments.length) { + throw Error("ee.List() only accepts 1 argument."); + } + if (list instanceof ee.List) { + return list; + } + } else { return ee.ComputedObject.construct(ee.List, arguments); } - if (list instanceof ee.List) { - return list; - } ee.List.initialize(); if (goog.isArray(list)) { ee.ComputedObject.call(this, null, null), this.list_ = list; diff --git a/javascript/src/geometry.js b/javascript/src/geometry.js index e385050..ad5b049 100644 --- a/javascript/src/geometry.js +++ b/javascript/src/geometry.js @@ -491,12 +491,12 @@ ee.Geometry.isValidGeometry_ = function(geometry) { var coords = geometry['coordinates']; var nesting = ee.Geometry.isValidCoordinates_(coords); return (type == 'Point' && nesting == 1) || - (type == 'MultiPoint' && nesting == 2) || + (type == 'MultiPoint' && (nesting == 2 || coords.length == 0)) || (type == 'LineString' && nesting == 2) || (type == 'LinearRing' && nesting == 2) || - (type == 'MultiLineString' && nesting == 3) || + (type == 'MultiLineString' && (nesting == 3 || coords.length == 0)) || (type == 'Polygon' && nesting == 3) || - (type == 'MultiPolygon' && nesting == 4); + (type == 'MultiPolygon' && (nesting == 4 || coords.length == 0)); } }; @@ -597,6 +597,11 @@ ee.Geometry.makeGeometry_ = function(geometry, nesting, opt_coordinates) { throw Error('Invalid geometry'); } + // Empty arrays should not be wrapped. + if (geometry.length == 1 && geometry[0].length == 0) { + geometry = []; + } + return /** @type {!Array.<*>} */ (geometry); }; diff --git a/javascript/src/list.js b/javascript/src/list.js index 897ec33..a6703b0 100644 --- a/javascript/src/list.js +++ b/javascript/src/list.js @@ -23,6 +23,8 @@ ee.List = function(list) { // Constructor safety. if (!(this instanceof ee.List)) { return ee.ComputedObject.construct(ee.List, arguments); + } else if (arguments.length > 1) { + throw Error('ee.List() only accepts 1 argument.'); } else if (list instanceof ee.List) { return list; } diff --git a/python/ee/__init__.py b/python/ee/__init__.py index e64cb4e..057605f 100644 --- a/python/ee/__init__.py +++ b/python/ee/__init__.py @@ -1,7 +1,7 @@ """The EE Javascript library.""" -__version__ = '0.1.49' +__version__ = '0.1.50' # Using lowercase function naming to match the JavaScript names. # pylint: disable=g-bad-name diff --git a/python/ee/geometry.py b/python/ee/geometry.py index 883e313..7a73014 100644 --- a/python/ee/geometry.py +++ b/python/ee/geometry.py @@ -148,8 +148,7 @@ class Geometry(computedobject.ComputedObject): """ return Geometry({ 'type': 'MultiPoint', - 'coordinates': Geometry._makeGeometry( - coordinates[0], 2, coordinates[1:]) + 'coordinates': Geometry._makeGeometry(2, coordinates) }) @staticmethod @@ -184,8 +183,7 @@ class Geometry(computedobject.ComputedObject): """ return Geometry({ 'type': 'LineString', - 'coordinates': Geometry._makeGeometry( - coordinates[0], 2, coordinates[1:]) + 'coordinates': Geometry._makeGeometry(2, coordinates) }) @staticmethod @@ -202,8 +200,7 @@ class Geometry(computedobject.ComputedObject): """ return Geometry({ 'type': 'LinearRing', - 'coordinates': Geometry._makeGeometry( - coordinates[0], 2, coordinates[1:]) + 'coordinates': Geometry._makeGeometry(2, coordinates) }) @staticmethod @@ -227,8 +224,7 @@ class Geometry(computedobject.ComputedObject): """ return Geometry({ 'type': 'MultiLineString', - 'coordinates': Geometry._makeGeometry( - coordinates[0], 3, coordinates[1:]) + 'coordinates': Geometry._makeGeometry(3, coordinates) }) @staticmethod @@ -250,8 +246,7 @@ class Geometry(computedobject.ComputedObject): """ return Geometry({ 'type': 'Polygon', - 'coordinates': Geometry._makeGeometry( - coordinates[0], 3, coordinates[1:]) + 'coordinates': Geometry._makeGeometry(3, coordinates) }) @staticmethod @@ -272,8 +267,7 @@ class Geometry(computedobject.ComputedObject): """ return Geometry({ 'type': 'MultiPolygon', - 'coordinates': Geometry._makeGeometry( - coordinates[0], 4, coordinates[1:]) + 'coordinates': Geometry._makeGeometry(4, coordinates) }) def encode(self, opt_encoder=None): # pylint: disable=unused-argument @@ -349,12 +343,15 @@ class Geometry(computedobject.ComputedObject): coords = geometry.get('coordinates') nesting = Geometry._isValidCoordinates(coords) return ((geometry_type == 'Point' and nesting == 1) or - (geometry_type == 'MultiPoint' and nesting == 2) or + (geometry_type == 'MultiPoint' and + (nesting == 2 or not coords)) or (geometry_type == 'LineString' and nesting == 2) or (geometry_type == 'LinearRing' and nesting == 2) or - (geometry_type == 'MultiLineString' and nesting == 3) or + (geometry_type == 'MultiLineString' and + (nesting == 3 or not coords)) or (geometry_type == 'Polygon' and nesting == 3) or - (geometry_type == 'MultiPolygon' and nesting == 4)) + (geometry_type == 'MultiPolygon' and + (nesting == 4 or not coords))) @staticmethod def _isValidCoordinates(shape): @@ -369,8 +366,7 @@ class Geometry(computedobject.ComputedObject): if not isinstance(shape, collections.Iterable): return -1 - shape = list(shape) - if isinstance(shape[0], collections.Iterable): + if shape and isinstance(shape[0], collections.Iterable): count = Geometry._isValidCoordinates(shape[0]) # If more than 1 ring or polygon, they should have the same nesting. for i in xrange(1, len(shape)): @@ -379,8 +375,8 @@ class Geometry(computedobject.ComputedObject): return count + 1 else: # Make sure the pts are all numbers. - for i in xrange(0, len(shape)): - if not isinstance(shape[i], numbers.Number): + for i in shape: + if not isinstance(i, numbers.Number): return -1 # Test that we have an even number of pts. @@ -400,7 +396,7 @@ class Geometry(computedobject.ComputedObject): Returns: An array of pairs of points. """ - if isinstance(coordinates[0], numbers.Number): + if coordinates and isinstance(coordinates[0], numbers.Number): line = [] if len(coordinates) % 2 != 0: raise ee_exception.EEException('Invalid number of coordinates: %s' % @@ -413,7 +409,7 @@ class Geometry(computedobject.ComputedObject): return coordinates @staticmethod - def _makeGeometry(geometry, nesting, opt_coordinates=()): + def _makeGeometry(nesting, opt_coordinates=()): """Check that the given geometry has the specified level of nesting. If the user passed a list of points to one of the Geometry functions, @@ -422,9 +418,8 @@ class Geometry(computedobject.ComputedObject): Polygon(1,2,3,4,5,6) and Polygon([[[1,2],[3,4],[5,6]]]) Args: - geometry: The geometry to check. nesting: The expected level of array nesting. - opt_coordinates: A list of extra coordinates to decode. + opt_coordinates: A list of all the coordinates to decode. Returns: The processed geometry. @@ -436,16 +431,17 @@ class Geometry(computedobject.ComputedObject): raise ee_exception.EEException('Unexpected nesting level.') # Handle a list of points. - if isinstance(geometry, numbers.Number) and opt_coordinates: - coordinates = [geometry] - coordinates.extend(opt_coordinates) - geometry = Geometry._coordinatesToLine(coordinates) + if (len(opt_coordinates) == 1 and + isinstance(opt_coordinates[0], (list, tuple))): + geometry = opt_coordinates[0] + else: + geometry = Geometry._coordinatesToLine(opt_coordinates) # Make sure the number of nesting levels is correct. item = geometry count = 0 - while isinstance(item, list) or isinstance(item, tuple): - item = item[0] + while isinstance(item, (list, tuple)): + item = item[0] if item else None count += 1 while count < nesting: @@ -455,6 +451,9 @@ class Geometry(computedobject.ComputedObject): if Geometry._isValidCoordinates(geometry) != nesting: raise ee_exception.EEException('Invalid geometry.') + # Empty arrays should not be wrapped. + if list(geometry) in ([[]], [()]): geometry = [] + return geometry @staticmethod diff --git a/python/ee/tests/geometry_test.py b/python/ee/tests/geometry_test.py index 86ded15..1c120bf 100644 --- a/python/ee/tests/geometry_test.py +++ b/python/ee/tests/geometry_test.py @@ -18,6 +18,7 @@ class GeometryTest(apitestcase.ApiTestCase): def testValid_MultiPoint(self): """Verifies MultiPoint constructor behavior with valid arguments.""" self.assertValid(2, ee.Geometry.MultiPoint, 1, 2, 3, 4, 5, 6) + self.assertValid(1, ee.Geometry.MultiPoint) def testValid_LineString(self): """Verifies LineString constructor behavior with valid arguments."""