How to use getpath method in tox

Best Python code snippet using tox_python

v3_epoly.js

Source:v3_epoly.js Github

copy

Full Screen

1/*********************************************************************\2* *3* epolys.js by Mike Williams *4* updated to API v3 by Larry Ross *5* *6* A Google Maps API Extension *7* *8* Adds various Methods to google.maps.Polygon and google.maps.Polyline *9* *10* .Contains(latlng) returns true is the poly contains the specified *11* GLatLng *12* *13* .Area() returns the approximate area of a poly that is *14* not self-intersecting *15* *16* .Distance() returns the length of the poly path *17* *18* .Bounds() returns a GLatLngBounds that bounds the poly *19* *20* .GetPointAtDistance() returns a GLatLng at the specified distance *21* along the path. *22* The distance is specified in metres *23* Reurns null if the path is shorter than that *24* *25* .GetPointsAtDistance() returns an array of GLatLngs at the *26* specified interval along the path. *27* The distance is specified in metres *28* *29* .GetIndexAtDistance() returns the vertex number at the specified *30* distance along the path. *31* The distance is specified in metres *32* Returns null if the path is shorter than that *33* *34* .Bearing(v1?,v2?) returns the bearing between two vertices *35* if v1 is null, returns bearing from first to last *36* if v2 is null, returns bearing from v1 to next *37* *38* *39***********************************************************************40* *41* This Javascript is provided by Mike Williams *42* Blackpool Community Church Javascript Team *43* http://www.blackpoolchurch.org/ *44* http://econym.org.uk/gmap/ *45* *46* This work is licenced under a Creative Commons Licence *47* http://creativecommons.org/licenses/by/2.0/uk/ *48* *49***********************************************************************50* *51* Version 1.1 6-Jun-2007 *52* Version 1.2 1-Jul-2007 - fix: Bounds was omitting vertex zero *53* add: Bearing *54* Version 1.3 28-Nov-2008 add: GetPointsAtDistance() *55* Version 1.4 12-Jan-2009 fix: GetPointsAtDistance() *56* Version 3.0 11-Aug-2010 update to v3 *57* *58\*********************************************************************/59// === first support methods that don't (yet) exist in v360google.maps.LatLng.prototype.distanceFrom = function(newLatLng) {61 var EarthRadiusMeters = 6378137.0; // meters62 var lat1 = this.lat();63 var lon1 = this.lng();64 var lat2 = newLatLng.lat();65 var lon2 = newLatLng.lng();66 var dLat = (lat2-lat1) * Math.PI / 180;67 var dLon = (lon2-lon1) * Math.PI / 180;68 var a = Math.sin(dLat/2) * Math.sin(dLat/2) +69 Math.cos(lat1 * Math.PI / 180 ) * Math.cos(lat2 * Math.PI / 180 ) *70 Math.sin(dLon/2) * Math.sin(dLon/2);71 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));72 var d = EarthRadiusMeters * c;73 return d;74}75google.maps.LatLng.prototype.latRadians = function() {76 return this.lat() * Math.PI/180;77}78google.maps.LatLng.prototype.lngRadians = function() {79 return this.lng() * Math.PI/180;80}81// === A method for testing if a point is inside a polygon82// === Returns true if poly contains point83// === Algorithm shamelessly stolen from http://alienryderflex.com/polygon/ 84google.maps.Polygon.prototype.Contains = function(point) {85 var j=0;86 var oddNodes = false;87 var x = point.lng();88 var y = point.lat();89 for (var i=0; i < this.getPath().getLength(); i++) {90 j++;91 if (j == this.getPath().getLength()) {j = 0;}92 if (((this.getPath().getAt(i).lat() < y) && (this.getPath().getAt(j).lat() >= y))93 || ((this.getPath().getAt(j).lat() < y) && (this.getPath().getAt(i).lat() >= y))) {94 if ( this.getPath().getAt(i).lng() + (y - this.getPath().getAt(i).lat())95 / (this.getPath().getAt(j).lat()-this.getPath().getAt(i).lat())96 * (this.getPath().getAt(j).lng() - this.getPath().getAt(i).lng())<x ) {97 oddNodes = !oddNodes98 }99 }100 }101 return oddNodes;102}103// === A method which returns the approximate area of a non-intersecting polygon in square metres ===104// === It doesn't fully account for spherical geometry, so will be inaccurate for large polygons ===105// === The polygon must not intersect itself ===106google.maps.Polygon.prototype.Area = function() {107 var a = 0;108 var j = 0;109 var b = this.Bounds();110 var x0 = b.getSouthWest().lng();111 var y0 = b.getSouthWest().lat();112 for (var i=0; i < this.getPath().getLength(); i++) {113 j++;114 if (j == this.getPath().getLength()) {j = 0;}115 var x1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(this.getPath().getAt(i).lat(),x0));116 var x2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(this.getPath().getAt(j).lat(),x0));117 var y1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(i).lng()));118 var y2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(y0,this.getPath().getAt(j).lng()));119 a += x1*y2 - x2*y1;120 }121 return Math.abs(a * 0.5);122}123// === A method which returns the length of a path in metres ===124google.maps.Polygon.prototype.Distance = function() {125 var dist = 0;126 for (var i=1; i < this.getPath().getLength(); i++) {127 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));128 }129 return dist;130}131// === A method which returns the bounds as a GLatLngBounds ===132google.maps.Polygon.prototype.Bounds = function() {133 var bounds = new google.maps.LatLngBounds();134 for (var i=0; i < this.getPath().getLength(); i++) {135 bounds.extend(this.getPath().getAt(i));136 }137 return bounds;138}139// === A method which returns a GLatLng of a point a given distance along the path ===140// === Returns null if the path is shorter than the specified distance ===141google.maps.Polygon.prototype.GetPointAtDistance = function(metres) {142 // some awkward special cases143 if (metres == 0) return this.getPath().getAt(0);144 if (metres < 0) return null;145 if (this.getPath().getLength() < 2) return null;146 var dist=0;147 var olddist=0;148 for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {149 olddist = dist;150 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));151 }152 if (dist < metres) {153 return null;154 }155 var p1= this.getPath().getAt(i-2);156 var p2= this.getPath().getAt(i-1);157 var m = (metres-olddist)/(dist-olddist);158 return new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m);159}160// === A method which returns an array of GLatLngs of points a given interval along the path ===161google.maps.Polygon.prototype.GetPointsAtDistance = function(metres) {162 var next = metres;163 var points = [];164 // some awkward special cases165 if (metres <= 0) return points;166 var dist=0;167 var olddist=0;168 for (var i=1; (i < this.getPath().getLength()); i++) {169 olddist = dist;170 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));171 while (dist > next) {172 var p1= this.getPath().getAt(i-1);173 var p2= this.getPath().getAt(i);174 var m = (next-olddist)/(dist-olddist);175 points.push(new google.maps.LatLng( p1.lat() + (p2.lat()-p1.lat())*m, p1.lng() + (p2.lng()-p1.lng())*m));176 next += metres; 177 }178 }179 return points;180}181// === A method which returns the Vertex number at a given distance along the path ===182// === Returns null if the path is shorter than the specified distance ===183google.maps.Polygon.prototype.GetIndexAtDistance = function(metres) {184 // some awkward special cases185 if (metres == 0) return this.getPath().getAt(0);186 if (metres < 0) return null;187 var dist=0;188 var olddist=0;189 for (var i=1; (i < this.getPath().getLength() && dist < metres); i++) {190 olddist = dist;191 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i-1));192 }193 if (dist < metres) {return null;}194 return i;195}196// === A function which returns the bearing between two vertices in decgrees from 0 to 360===197// === If v1 is null, it returns the bearing between the first and last vertex ===198// === If v1 is present but v2 is null, returns the bearing from v1 to the next vertex ===199// === If either vertex is out of range, returns void ===200google.maps.Polygon.prototype.Bearing = function(v1,v2) {201 if (v1 == null) {202 v1 = 0;203 v2 = this.getPath().getLength()-1;204 } else if (v2 == null) {205 v2 = v1+1;206 }207 if ((v1 < 0) || (v1 >= this.getPath().getLength()) || (v2 < 0) || (v2 >= this.getPath().getLength())) {208 return;209 }210 var from = this.getPath().getAt(v1);211 var to = this.getPath().getAt(v2);212 if (from.equals(to)) {213 return 0;214 }215 var lat1 = from.latRadians();216 var lon1 = from.lngRadians();217 var lat2 = to.latRadians();218 var lon2 = to.lngRadians();219 var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );220 if ( angle < 0.0 ) angle += Math.PI * 2.0;221 angle = angle * 180.0 / Math.PI;222 return parseFloat(angle.toFixed(1));223}224// === Copy all the above functions to GPolyline ===225google.maps.Polyline.prototype.Contains = google.maps.Polygon.prototype.Contains;226google.maps.Polyline.prototype.Area = google.maps.Polygon.prototype.Area;227google.maps.Polyline.prototype.Distance = google.maps.Polygon.prototype.Distance;228google.maps.Polyline.prototype.Bounds = google.maps.Polygon.prototype.Bounds;229google.maps.Polyline.prototype.GetPointAtDistance = google.maps.Polygon.prototype.GetPointAtDistance;230google.maps.Polyline.prototype.GetPointsAtDistance = google.maps.Polygon.prototype.GetPointsAtDistance;231google.maps.Polyline.prototype.GetIndexAtDistance = google.maps.Polygon.prototype.GetIndexAtDistance;...

Full Screen

Full Screen

polygon_edit.js

Source:polygon_edit.js Github

copy

Full Screen

1if (typeof(google.maps.Polygon.prototype.runEdit) === "undefined") {2 /**3 * Starts editing the polygon. Optional parameter <code>flag</code>4 * indicates the use of ghost markers in the middle of each segment. By5 * default, the <code>flag</code> is true.6 * 7 * @param {}8 * flag - (true) include additional points in the middle of each9 * segment10 */11 google.maps.Polygon.prototype.runEdit = function (flag) {12 if (!flag) {13 flag = true;14 }15 var self = this;16 if (flag) {17 var imgGhostVertex = new google.maps.MarkerImage(18 'css/ghostVertex.png', new google.maps.Size(11, 11),19 new google.maps.Point(0, 0), new google.maps.Point(6, 6));20 var imgGhostVertexOver = new google.maps.MarkerImage(21 'css/ghostVertexOver.png', new google.maps.Size(11, 11),22 new google.maps.Point(0, 0), new google.maps.Point(6, 6));23 var ghostPath = new google.maps.Polygon({24 map : this.getMap(),25 strokeColor : this.strokeColor,26 strokeOpacity : 0.2,27 strokeWeight : this.strokeWeight28 });29 var vertexGhostMouseOver = function () {30 this.setIcon(imgGhostVertexOver);31 };32 var vertexGhostMouseOut = function () {33 this.setIcon(imgGhostVertex);34 };35 var vertexGhostDrag = function () {36 if (ghostPath.getPath().getLength() === 0) {37 if (this.marker.inex < self.getPath().getLength() - 1) {38 ghostPath.setPath([this.marker.getPosition(), this.getPosition(), self.getPath().getAt(this.marker.inex + 1)]);39 } else {40 if (this.marker.inex === self.getPath().getLength() - 1) {41 ghostPath.setPath([this.marker.getPosition(), this.getPosition(), self.getPath().getAt(0)]);42 }43 }44 } 45 ghostPath.getPath().setAt(1, this.getPosition());46 };47 var moveGhostMarkers = function (marker) {48 var Vertex = self.getPath().getAt(marker.inex);49 if (marker.inex === 0) {50 var prevVertex = self.getPath().getAt(self.getPath().getLength() - 1);51 } else {52 var prevVertex = self.getPath().getAt(marker.inex - 1);53 }54 if ((typeof(Vertex) !== "undefined") && (typeof(Vertex.ghostMarker) !== "undefined")) {55 if (typeof(google.maps.geometry) === "undefined") {56 if (marker.inex < self.getPath().getLength() - 1) {57 Vertex.ghostMarker.setPosition(new google.maps.LatLng(Vertex.lat() + 0.5 * (self.getPath().getAt(marker.inex + 1).lat() - Vertex.lat()), Vertex.lng() + 0.5 * (self.getPath().getAt(marker.inex + 1).lng() - Vertex.lng())));58 } else {59 if (marker.inex === self.getPath().getLength() - 1) {60 Vertex.ghostMarker.setPosition(new google.maps.LatLng(Vertex.lat() + 0.5 * (self.getPath().getAt(0).lat() - Vertex.lat()), Vertex.lng() + 0.5 * (self.getPath().getAt(0).lng() - Vertex.lng())));61 }62 }63 } else {64 if (marker.inex < self.getPath().getLength() - 1) {65 Vertex.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(Vertex, self.getPath().getAt(marker.inex + 1), 0.5));66 } else {67 if (marker.inex === self.getPath().getLength() - 1) {68 Vertex.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(Vertex, self.getPath().getAt(0), 0.5));69 }70 }71 }72 } 73 if ((typeof(prevVertex) !== "undefined") && (typeof(prevVertex.ghostMarker) !== "undefined")) {74 if (typeof(google.maps.geometry) === "undefined") {75 prevVertex.ghostMarker.setPosition(new google.maps.LatLng(prevVertex.lat() + 0.5 * (marker.getPosition().lat() - prevVertex.lat()), prevVertex.lng() + 0.5 * (marker.getPosition().lng() - prevVertex.lng())));76 } else {77 prevVertex.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(prevVertex, marker.getPosition(), 0.5));78 }79 }80 };81 var vertexGhostDragEnd = function () {82 ghostPath.getPath().forEach(function () {83 ghostPath.getPath().pop();84 });85 self.getPath().insertAt(this.marker.inex + 1, this.getPosition());86 createMarkerVertex(self.getPath().getAt(this.marker.inex + 1)).inex = this.marker.inex + 1;87 moveGhostMarkers(this.marker);88 createGhostMarkerVertex(self.getPath().getAt(this.marker.inex + 1));89 self.getPath().forEach(function (vertex, inex) {90 if (vertex.marker) {91 vertex.marker.inex = inex;92 }93 });94 };95 var createGhostMarkerVertex = function (point) {96 if (point.marker.inex < self.getPath().getLength() - 1) {97 var markerGhostVertex = new google.maps.Marker({98 position : (typeof(google.maps.geometry) === "undefined") ? new google.maps.LatLng(99 point.lat() + 0.5 * (self.getPath().getAt(point.marker.inex + 1).lat() - point.lat()),100 point.lng() + 0.5 * (self.getPath().getAt(point.marker.inex + 1).lng() - point.lng()))101 :google.maps.geometry.spherical.interpolate(point, self.getPath().getAt(point.marker.inex + 1), 0.5),102 map : self.getMap(),103 icon : imgGhostVertex,104 draggable : true,105 raiseOnDrag : false106 });107 google.maps.event.addListener(markerGhostVertex, "mouseover", vertexGhostMouseOver);108 google.maps.event.addListener(markerGhostVertex, "mouseout", vertexGhostMouseOut);109 google.maps.event.addListener(markerGhostVertex, "drag", vertexGhostDrag);110 google.maps.event.addListener(markerGhostVertex, "dragend", vertexGhostDragEnd);111 point.ghostMarker = markerGhostVertex;112 markerGhostVertex.marker = point.marker;113 return markerGhostVertex;114 } else {115 if (point.marker.inex === self.getPath().getLength() - 1) {116 var markerGhostVertex = new google.maps.Marker({117 position : (typeof(google.maps.geometry) === "undefined") ? new google.maps.LatLng(118 point.lat() + 0.5 * (self.getPath().getAt(0).lat() - point.lat()),119 point.lng() + 0.5 * (self.getPath().getAt(0).lng() - point.lng()))120 :google.maps.geometry.spherical.interpolate(point, self.getPath().getAt(0), 0.5),121 map : self.getMap(),122 icon : imgGhostVertex,123 draggable : true,124 raiseOnDrag : false125 });126 google.maps.event.addListener(markerGhostVertex, "mouseover", vertexGhostMouseOver);127 google.maps.event.addListener(markerGhostVertex, "mouseout", vertexGhostMouseOut);128 google.maps.event.addListener(markerGhostVertex, "drag", vertexGhostDrag);129 google.maps.event.addListener(markerGhostVertex, "dragend", vertexGhostDragEnd);130 point.ghostMarker = markerGhostVertex;131 markerGhostVertex.marker = point.marker;132 return markerGhostVertex;133 }134 }135 return null;136 };137 }138 var imgVertex = new google.maps.MarkerImage('css/vertex.png',139 new google.maps.Size(11, 11), new google.maps.Point(0, 0),140 new google.maps.Point(6, 6));141 var imgVertexOver = new google.maps.MarkerImage('css/vertexOver.png',142 new google.maps.Size(11, 11), new google.maps.Point(0, 0),143 new google.maps.Point(6, 6));144 var vertexMouseOver = function () {145 this.setIcon(imgVertexOver);146 };147 var vertexMouseOut = function () {148 this.setIcon(imgVertex);149 };150 var vertexDrag = function () {151 var movedVertex = this.getPosition();152 movedVertex.marker = this;153 movedVertex.ghostMarker = self.getPath().getAt(this.inex).ghostMarker;154 self.getPath().setAt(this.inex, movedVertex);155 if (flag) {156 moveGhostMarkers(this);157 }158 };159 var vertexRightClick = function () {160 if (flag) {161 var Vertex = self.getPath().getAt(this.inex);162 if (this.inex === 0) {163 var prevVertex = self.getPath().getAt(self.getPath().getLength() - 1);164 } else {165 var prevVertex = self.getPath().getAt(this.inex - 1);166 }167 if (typeof(Vertex.ghostMarker) !== "undefined") {168 Vertex.ghostMarker.setMap(null);169 }170 self.getPath().removeAt(this.inex);171 self.getPath().forEach(function (vertex, inex) {172 if (vertex.marker) {173 vertex.marker.inex = inex;174 }175 });176 if (typeof(prevVertex) !== "undefined") {177 if (this.inex <= self.getPath().getLength() ) {178 moveGhostMarkers(prevVertex.marker);179 } else {180 prevVertex.ghostMarker.setMap(null);181 prevVertex.ghostMarker = undefined;182 }183 }184 } 185 else {186 self.getPath().removeAt(this.inex);187 }188 this.setMap(null);189 if (self.getPath().getLength() === 1) {190 prevVertex.ghostMarker.setMap(null);191 self.getPath().pop().marker.setMap(null);192 }193 };194 var createMarkerVertex = function (point) {195 var markerVertex = new google.maps.Marker({196 position : point,197 map : self.getMap(),198 icon : imgVertex,199 draggable : true,200 raiseOnDrag : false201 });202 google.maps.event.addListener(markerVertex, "mouseover", vertexMouseOver);203 google.maps.event.addListener(markerVertex, "mouseout", vertexMouseOut);204 google.maps.event.addListener(markerVertex, "drag", vertexDrag);205 google.maps.event.addListener(markerVertex, "rightclick", vertexRightClick);206 point.marker = markerVertex;207 return markerVertex;208 };209 this.getPath().forEach(function (vertex, inex) {210 createMarkerVertex(vertex).inex = inex;211 if (flag) {212 createGhostMarkerVertex(vertex);213 }214 });215 };216}217if (typeof(google.maps.Polygon.prototype.stopEdit) === "undefined") {218 /**219 * Stops editing Polygon220 */221 google.maps.Polygon.prototype.stopEdit = function () {222 this.getPath().forEach(function (vertex, inex) {223 if (vertex.marker) {224 vertex.marker.setMap(null);225 vertex.marker = undefined;226 }227 if (vertex.ghostMarker) {228 vertex.ghostMarker.setMap(null);229 vertex.ghostMarker = undefined;230 }231 });232 }; ...

Full Screen

Full Screen

dirUtils.js

Source:dirUtils.js Github

copy

Full Screen

1if(typeof(JS_LIB_LOADED)=='boolean') 2{3 var JS_DIRUTILS_FILE = "dirUtils.js";4 var JS_DIRUTILS_LOADED = true;5 6 var JS_DIRUTILS_FILE_DIR_CID = "@mozilla.org/file/directory_service;1";7 8 var JS_DIRUTILS_I_PROPS = "nsIProperties";9 var JS_DIRUTILS_NSIFILE = jslibI.nsIFile;10 11 /** 12 * /root/.mozilla/Default User/k1m30xaf.slt13 */14 var NS_APP_PREFS_50_DIR = "PrefD"; 15 16 /**17 * /usr/src/mozilla/dist/bin/chrome18 */19 var NS_APP_CHROME_DIR = "AChrom"; 20 21 /**22 * /root/.mozilla23 */24 var NS_APP_USER_PROFILES_ROOT_DIR = "DefProfRt"; 25 26 /**27 * /root/.mozilla/Default User/k1m30xaf.slt28 */29 var NS_APP_USER_PROFILE_50_DIR = "ProfD"; 30 31 /**32 * /root/.mozilla33 */34 var NS_APP_APPLICATION_REGISTRY_DIR = "AppRegD"; 35 36 /** 37 * /root/.mozilla/appreg38 */39 var NS_APP_APPLICATION_REGISTRY_FILE = "AppRegF"; 40 41 /** 42 * /usr/src/mozilla/dist/bin/defaults 43 */44 var NS_APP_DEFAULTS_50_DIR = "DefRt"; 45 46 /**47 * /usr/src/mozilla/dist/bin/defaults/pref48 */49 var NS_APP_PREF_DEFAULTS_50_DIR = "PrfDef"; 50 51 /**52 * /usr/src/mozilla/dist/bin/defaults/profile/US53 */54 var NS_APP_PROFILE_DEFAULTS_50_DIR = "profDef"; 55 56 /** 57 * /usr/src/mozilla/dist/bin/defaults/profile 58 */59 var NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR = "ProfDefNoLoc"; 60 61 /** 62 * /usr/src/mozilla/dist/bin/res63 */64 var NS_APP_RES_DIR = "ARes"; 65 66 /** 67 * /usr/src/mozilla/dist/bin/plugins68 */69 var NS_APP_PLUGINS_DIR = "APlugns"; 70 71 /** 72 * /usr/src/mozilla/dist/bin/searchplugins73 */74 var NS_APP_SEARCH_DIR = "SrchPlugns"; 75 76 /**77 * /root/.mozilla/Default User/k1m30xaf.slt/prefs.js78 */79 var NS_APP_PREFS_50_FILE = "PrefF"; 80 81 /** 82 * /root/.mozilla/Default User/k1m30xaf.slt/chrome83 */84 var NS_APP_USER_CHROME_DIR = "UChrm"; 85 86 /** 87 * /root/.mozilla/Default User/k1m30xaf.slt/localstore.rdf88 */89 var NS_APP_LOCALSTORE_50_FILE = "LclSt"; 90 91 /** 92 * /root/.mozilla/Default User/k1m30xaf.slt/history.dat93 */94 var NS_APP_HISTORY_50_FILE = "UHist"; 95 96 /** 97 * /root/.mozilla/Default User/k1m30xaf.slt/panels.rdf98 */99 var NS_APP_USER_PANELS_50_FILE = "UPnls"; 100 101 /** 102 * /root/.mozilla/Default User/k1m30xaf.slt/mimeTypes.rdf103 */104 var NS_APP_USER_MIMETYPES_50_FILE = "UMimTyp"; 105 106 /** 107 * /root/.mozilla/Default User/k1m30xaf.slt/bookmarks.html 108 */109 var NS_APP_BOOKMARKS_50_FILE = "BMarks"; 110 111 /** 112 * /root/.mozilla/Default User/k1m30xaf.slt/search.rdf113 */114 var NS_APP_SEARCH_50_FILE = "SrchF"; 115 116 /**117 * /root/.mozilla/Default User/k1m30xaf.slt/Mail118 */119 var NS_APP_MAIL_50_DIR = "MailD"; 120 121 /**122 * /root/.mozilla/Default User/k1m30xaf.slt/ImapMail123 */124 var NS_APP_IMAP_MAIL_50_DIR = "IMapMD"; 125 126 /**127 * /root/.mozilla/Default User/k1m30xaf.slt/News128 */129 var NS_APP_NEWS_50_DIR = "NewsD"; 130 131 /** 132 * /root/.mozilla/Default User/k1m30xaf.slt/panacea.dat133 */134 var NS_APP_MESSENGER_FOLDER_CACHE_50_DIR = "MFCaD"; 135 136 // Useful OS System Dirs137 138 /** 139 * /usr/src/mozilla/dist/bin140 */141 var NS_OS_CURRENT_PROCESS_DIR = "CurProcD"; 142 143 var NS_OS_DESKTOP_DIR = "Desk";144 145 /** 146 * /root147 */148 var NS_OS_HOME_DIR = "Home"; 149 150 /** 151 * /tmp152 */153 var NS_OS_TEMP_DIR = "TmpD"; 154 155 /**156 * /usr/src/mozilla/dist/bin/components157 */158 var NS_XPCOM_COMPONENT_DIR = "ComsD"; 159 160 // varructor161 function DirUtils () {}162 163 DirUtils.prototype = 164 {165 useObj : false, 166 getPath : function (aAppID) 167 {168 if(!aAppID)169 return jslibErrorMsg("NS_ERROR_INVALID_ARG");170 171 var rv;172 try { 173 rv = jslibGetService(JS_DIRUTILS_FILE_DIR_CID, JS_DIRUTILS_I_PROPS)174 .get(aAppID, JS_DIRUTILS_NSIFILE); 175 if (this.useObj) {176 if (rv.isFile()) {177 include(jslib_file);178 rv = new File(rv.path);179 } else if (rv.isDirectory()) {180 include(jslib_dir);181 rv = new Dir(rv.path);182 }183 } else {184 rv = rv.path;185 }186 } catch (e) { rv = jslibError(e); }187 188 return rv;189 },190 191 getPrefsDir :192 function () { return this.getPath(NS_APP_PREFS_50_DIR); },193 getChromeDir :194 function () { return this.getPath(NS_APP_CHROME_DIR); },195 getMozHomeDir : 196 function () { return this.getPath(NS_APP_USER_PROFILES_ROOT_DIR); },197 getMozUserHomeDir :198 function () { return this.getPath(NS_APP_USER_PROFILE_50_DIR); },199 getAppRegDir : 200 function () { return this.getPath(NS_APP_APPLICATION_REGISTRY_FILE); },201 getAppDefaultDir : 202 function () { return this.getPath(NS_APP_DEFAULTS_50_DIR); },203 getAppDefaultPrefDir :204 function () { return this.getPath(NS_APP_PREF_DEFAULTS_50_DIR); },205 getProfileDefaultsLocDir : 206 function () { return this.getPath(NS_APP_PROFILE_DEFAULTS_50_DIR); },207 getProfileDefaultsDir :208 function () { return this.getPath(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR); },209 getAppResDir :210 function () { return this.getPath(NS_APP_RES_DIR); },211 getAppPluginsDir : 212 function () { return this.getPath(NS_APP_PLUGINS_DIR); },213 getSearchPluginsDir : 214 function () { return this.getPath(NS_APP_SEARCH_DIR); },215 getPrefsFile : 216 function () { return this.getPath(NS_APP_PREFS_50_FILE); },217 getUserChromeDir : 218 function () { return this.getPath(NS_APP_USER_CHROME_DIR); },219 getLocalStore :220 function () { return this.getPath(NS_APP_LOCALSTORE_50_FILE); },221 getHistoryFile : 222 function () { return this.getPath(NS_APP_HISTORY_50_FILE); },223 getPanelsFile :224 function () { return this.getPath(NS_APP_USER_PANELS_50_FILE); },225 getMimeTypes :226 function () { return this.getPath(NS_APP_USER_MIMETYPES_50_FILE); },227 getBookmarks : 228 function () { return this.getPath(NS_APP_BOOKMARKS_50_FILE); },229 getSearchFile : 230 function () { return this.getPath(NS_APP_SEARCH_50_FILE); },231 getUserMailDir : 232 function () { return this.getPath(NS_APP_MAIL_50_DIR); },233 getUserImapDir : 234 function () { return this.getPath(NS_APP_IMAP_MAIL_50_DIR); },235 getUserNewsDir :236 function () { return this.getPath(NS_APP_NEWS_50_DIR); },237 getMessengerFolderCache :238 function () { return this.getPath(NS_APP_MESSENGER_FOLDER_CACHE_50_DIR); },239 getCurProcDir : 240 function () { return this.getPath(NS_OS_CURRENT_PROCESS_DIR); },241 getHomeDir : 242 function () { return this.getPath(NS_OS_HOME_DIR); },243 getDesktopDir : 244 function () 245 { 246 include(jslib_system);247 var sys = new System;248 var os = sys.os;249 var key = "";250 var rv;251 if (os == "win32")252 key = "DeskP";253 else if (os == "macosx")254 key = "UsrDsk";255 else256 key = NS_OS_DESKTOP_DIR;257 rv = this.getPath(key);258 if (rv < 0)259 rv = null;260 return rv;261 },262 getTmpDir :263 function () { return this.getPath(NS_OS_TEMP_DIR); },264 getComponentsDir : 265 function () { return this.getPath(NS_XPCOM_COMPONENT_DIR); },266 get help () 267 {268 var help =269 "\n\nFunction and Attribute List:\n" +270 "\n" +271 " getPrefsDir()\n" +272 " getChromeDir()\n" +273 " getMozHomeDir()\n" +274 " getMozUserHomeDir()\n" +275 " getAppRegDir()\n" +276 " getAppDefaultDir()\n" +277 " getAppDefaultPrefDir()\n" +278 " getProfileDefaultsLocDir()\n" +279 " getProfileDefaultsDir()\n" +280 " getAppResDir()\n" +281 " getAppPluginsDir()\n" +282 " getSearchPluginsDir()\n" +283 " getPrefsFile()\n" +284 " getUserChromeDir()\n" +285 " getLocalStore()\n" +286 " getHistoryFile()\n" +287 " getPanelsFile()\n" +288 " getMimeTypes()\n" +289 " getBookmarks()\n" +290 " getSearchFile()\n" +291 " getUserMailDir()\n" +292 " getUserImapDir()\n" +293 " getUserNewsDir()\n" +294 " getMessengerFolderCache()\n" +295 " getCurProcDir()\n" +296 " getHomeDir()\n" +297 " getTmpDir()\n" + 298 " getComponentsDir()\n\n";299 300 return help;301 }302 }; 303 jslibLoadMsg(JS_DIRUTILS_FILE);304} else { dump("Load Failure: dirUtils.js\n"); }...

Full Screen

Full Screen

epoly.js

Source:epoly.js Github

copy

Full Screen

1// === first support methods that don't (yet) exist in v32google.maps.LatLng.prototype.distanceFrom = function(newLatLng) {3 var EarthRadiusMeters = 6378137.0; // meters4 var lat1 = this.lat();5 var lon1 = this.lng();6 var lat2 = newLatLng.lat();7 var lon2 = newLatLng.lng();8 var dLat = (lat2 - lat1) * Math.PI / 180;9 var dLon = (lon2 - lon1) * Math.PI / 180;10 var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +11 Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *12 Math.sin(dLon / 2) * Math.sin(dLon / 2);13 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));14 var d = EarthRadiusMeters * c;15 return d;16}17google.maps.LatLng.prototype.latRadians = function() {18 return this.lat() * Math.PI / 180;19}20google.maps.LatLng.prototype.lngRadians = function() {21 return this.lng() * Math.PI / 180;22}23// === A method for testing if a point is inside a polygon24// === Returns true if poly contains point25// === Algorithm shamelessly stolen from http://alienryderflex.com/polygon/ 26google.maps.Polygon.prototype.Contains = function(point) {27 var j = 0;28 var oddNodes = false;29 var x = point.lng();30 var y = point.lat();31 for (var i = 0; i < this.getPath().getLength(); i++) {32 j++;33 if (j == this.getPath().getLength()) {34 j = 0;35 }36 if (((this.getPath().getAt(i).lat() < y) && (this.getPath().getAt(j).lat() >= y)) || ((this.getPath().getAt(j).lat() < y) && (this.getPath().getAt(i).lat() >= y))) {37 if (this.getPath().getAt(i).lng() + (y - this.getPath().getAt(i).lat()) / (this.getPath().getAt(j).lat() - this.getPath().getAt(i).lat()) * (this.getPath().getAt(j).lng() - this.getPath().getAt(i).lng()) < x) {38 oddNodes = !oddNodes39 }40 }41 }42 return oddNodes;43}44// === A method which returns the approximate area of a non-intersecting polygon in square metres ===45// === It doesn't fully account for spherical geometry, so will be inaccurate for large polygons ===46// === The polygon must not intersect itself ===47google.maps.Polygon.prototype.Area = function() {48 var a = 0;49 var j = 0;50 var b = this.Bounds();51 var x0 = b.getSouthWest().lng();52 var y0 = b.getSouthWest().lat();53 for (var i = 0; i < this.getPath().getLength(); i++) {54 j++;55 if (j == this.getPath().getLength()) {56 j = 0;57 }58 var x1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(this.getPath().getAt(i).lat(), x0));59 var x2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(this.getPath().getAt(j).lat(), x0));60 var y1 = this.getPath().getAt(i).distanceFrom(new google.maps.LatLng(y0, this.getPath().getAt(i).lng()));61 var y2 = this.getPath().getAt(j).distanceFrom(new google.maps.LatLng(y0, this.getPath().getAt(j).lng()));62 a += x1 * y2 - x2 * y1;63 }64 return Math.abs(a * 0.5);65}66// === A method which returns the length of a path in metres ===67google.maps.Polygon.prototype.Distance = function() {68 var dist = 0;69 for (var i = 1; i < this.getPath().getLength(); i++) {70 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));71 }72 return dist;73}74// === A method which returns the bounds as a GLatLngBounds ===75google.maps.Polygon.prototype.Bounds = function() {76 var bounds = new google.maps.LatLngBounds();77 for (var i = 0; i < this.getPath().getLength(); i++) {78 bounds.extend(this.getPath().getAt(i));79 }80 return bounds;81}82// === A method which returns a GLatLng of a point a given distance along the path ===83// === Returns null if the path is shorter than the specified distance ===84google.maps.Polygon.prototype.GetPointAtDistance = function(metres) {85 // some awkward special cases86 if (metres == 0) return this.getPath().getAt(0);87 if (metres < 0) return null;88 if (this.getPath().getLength() < 2) return null;89 var dist = 0;90 var olddist = 0;91 for (var i = 1;92 (i < this.getPath().getLength() && dist < metres); i++) {93 olddist = dist;94 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));95 }96 if (dist < metres) {97 return null;98 }99 var p1 = this.getPath().getAt(i - 2);100 var p2 = this.getPath().getAt(i - 1);101 var m = (metres - olddist) / (dist - olddist);102 return new google.maps.LatLng(p1.lat() + (p2.lat() - p1.lat()) * m, p1.lng() + (p2.lng() - p1.lng()) * m);103}104// === A method which returns an array of GLatLngs of points a given interval along the path ===105google.maps.Polygon.prototype.GetPointsAtDistance = function(metres) {106 var next = metres;107 var points = [];108 // some awkward special cases109 if (metres <= 0) return points;110 var dist = 0;111 var olddist = 0;112 for (var i = 1;113 (i < this.getPath().getLength()); i++) {114 olddist = dist;115 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));116 while (dist > next) {117 var p1 = this.getPath().getAt(i - 1);118 var p2 = this.getPath().getAt(i);119 var m = (next - olddist) / (dist - olddist);120 points.push(new google.maps.LatLng(p1.lat() + (p2.lat() - p1.lat()) * m, p1.lng() + (p2.lng() - p1.lng()) * m));121 next += metres;122 }123 }124 return points;125}126// === A method which returns the Vertex number at a given distance along the path ===127// === Returns null if the path is shorter than the specified distance ===128google.maps.Polygon.prototype.GetIndexAtDistance = function(metres) {129 // some awkward special cases130 if (metres == 0) return this.getPath().getAt(0);131 if (metres < 0) return null;132 var dist = 0;133 var olddist = 0;134 for (var i = 1;135 (i < this.getPath().getLength() && dist < metres); i++) {136 olddist = dist;137 dist += this.getPath().getAt(i).distanceFrom(this.getPath().getAt(i - 1));138 }139 if (dist < metres) {140 return null;141 }142 return i;143}144// === A function which returns the bearing between two vertices in decgrees from 0 to 360===145// === If v1 is null, it returns the bearing between the first and last vertex ===146// === If v1 is present but v2 is null, returns the bearing from v1 to the next vertex ===147// === If either vertex is out of range, returns void ===148google.maps.Polygon.prototype.Bearing = function(v1, v2) {149 if (v1 == null) {150 v1 = 0;151 v2 = this.getPath().getLength() - 1;152 } else if (v2 == null) {153 v2 = v1 + 1;154 }155 if ((v1 < 0) || (v1 >= this.getPath().getLength()) || (v2 < 0) || (v2 >= this.getPath().getLength())) {156 return;157 }158 var from = this.getPath().getAt(v1);159 var to = this.getPath().getAt(v2);160 if (from.equals(to)) {161 return 0;162 }163 var lat1 = from.latRadians();164 var lon1 = from.lngRadians();165 var lat2 = to.latRadians();166 var lon2 = to.lngRadians();167 var angle = -Math.atan2(Math.sin(lon1 - lon2) * Math.cos(lat2), Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon1 - lon2));168 if (angle < 0.0) angle += Math.PI * 2.0;169 angle = angle * 180.0 / Math.PI;170 return parseFloat(angle.toFixed(1));171}172// === Copy all the above functions to GPolyline ===173google.maps.Polyline.prototype.Contains = google.maps.Polygon.prototype.Contains;174google.maps.Polyline.prototype.Area = google.maps.Polygon.prototype.Area;175google.maps.Polyline.prototype.Distance = google.maps.Polygon.prototype.Distance;176google.maps.Polyline.prototype.Bounds = google.maps.Polygon.prototype.Bounds;177google.maps.Polyline.prototype.GetPointAtDistance = google.maps.Polygon.prototype.GetPointAtDistance;178google.maps.Polyline.prototype.GetPointsAtDistance = google.maps.Polygon.prototype.GetPointsAtDistance;179google.maps.Polyline.prototype.GetIndexAtDistance = google.maps.Polygon.prototype.GetIndexAtDistance;...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful