profile
viewpoint
Philipp Loose phloose Hamburg, Germany

phloose/Leaflet 0

:leaves: JavaScript library for mobile-friendly interactive maps

phloose/leaflet-side-by-side 0

A Leaflet control to add a split screen to compare two map overlays

phloose/leaflet-splitmap 0

A Leaflet control to compare two map layers

phloose/pycval 0

PyCVal is a tiny command line tool based on pythons hashlib to validate checksums of arbitrary input (as string, std-input or file) against a user given checksum file or string - or to just calculate a checksum from user input.

phloose/pygmt 0

A Python interface for the Generic Mapping Tools

phloose/pytest 0

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

phloose/QGIS 0

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)

phloose/scoop-extras 0

"Extras" bucket for Scoop

phloose/Sourcetrail 0

Sourcetrail - free and open-source interactive source explorer

phloose/SourcetrailDB 0

Library to export Sourcetrail compatible database files for writing custom indexers

issue commentelectron-userland/electron-builder

Error when building on MacOS

Though closed i think this issue is related to the go version used (1.14): https://github.com/golang/go/issues/37459

Splode

comment created time in 12 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 5dd582e051291c9b9553145e4e80dd9bfc93022c

Only exclude src/leaflet-splitmap.js in .npmignore

view details

push time in 13 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha c0aa8007007840a112e0c2ff2bde1a1a7038dfcb

Add 'prepare' lifecycle hook Reference: https://stackoverflow.com/questions/48287776/automatically-build-npm-module-on-install-from-github

view details

push time in 13 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha d052d98f2433247713a3e3a4363fc261aa91e19d

Add 'prepare' lifecycle hook Reference: https://stackoverflow.com/questions/48287776/automatically-build-npm-module-on-install-from-github

view details

push time in 13 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 2a741366751fbbd6961987c3f730a601089b213e

Add 'prepare' lifecycle hook Reference: https://stackoverflow.com/questions/48287776/automatically-build-npm-module-on-install-from-github

view details

push time in 13 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 845621a30a6176266256c7ef54d06ed03600b22a

Don't ignore the compile webpack bundle when installing via npm

view details

push time in 13 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 8a2f0c0eb1ae4266506313dc95571a4e3de832da

Remove leaflet-splitmap.js from .npmignore

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 362facc5bae0b13628ba70a450356158b0e921fe

Add 'postinstall' script to create dist folder for proper usage of webpack

view details

push time in 14 days

push eventphloose/leaflet-splitmap

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 7095b5a62a061d50c910b101f57fe7c6f17480a0

Remove 'npm run clean' from prepublish script

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 3f3c53690cc96b8d648561fe447d9726473d1d98

Use files property to include the dist folder when installing via npm (removes .npmignore)

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha ef467feb2df7a437ce75392ecf7c2d341c574d84

Use files property to include the dist folder when installing via npm (removes .npmignore)

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha b2a4c611258ed4479a0fbd256b8e3fb99b3c042d

Use files property to also include the dist folder when installing via npm

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha a6d66653deb2d11ff31bf015f5520cae8f921781

Remove leaflet-splitmap.js from .npmignore

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 86b7120109c4365e5211c3824ed711d85db027c2

Use files property to also include the dist folder when installing via npm

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 58556e8094e742e5a3b546b7d19f622f58a850b6

Use files property to also include the dist folder when installing via npm

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 4313e921ea4985841f67c00b1ac3c208dc0b9d10

Use files property in package.json to include leaflet-splitmap.js when publishing

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha f30dd445554b4b8d9c75406bc21641be87c6778a

Remove leaflet-splitmap.js from .npmignore

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha cc9837a7d9bdddb0c1b46051909fe46cb9dc9e8f

Use publish instead of prepublish in package.json

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha 783c7b1ba56f1f7893ac2c92b20045b594b345e4

Use postinstall instead of prepublish in package.json

view details

push time in 14 days

push eventphloose/leaflet-splitmap

Philipp Loose

commit sha d8148fd7191a0b97b2594f265b29d24bc1de750c

Use prepare instead of prepublish in package.json

view details

push time in 14 days

create barnchphloose/leaflet-splitmap

branch : dev

created branch time in 14 days

pull request commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

Any news on this? @mourner maybe?

phloose

comment created time in a month

pull request commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

So is there anything left to do? ;)

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j] instanceof L.LatLng).to.be(true);+				}+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () {+			const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);+			const expected = [+				{lat: 2, lng: 3, alt: 4},+				{lat: 5, lng: 6, alt: 7},+				{lat: 8, lng: 9, alt: 10}+			];+			for (var i = 0; i < latLngs.length; i++) {+				expect(latLngs[i]).to.eql(expected[i]);+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () {+			const coords = [+				[[1, 2, 3], [4, 5, 6]],+				[[12, 13, 14], [15, 16, 17]]+			];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);+			const expected = [+				[+					{lat: 2, lng: 3, alt: 4},+					{lat: 5, lng: 6, alt: 7}+				],+				[+					{lat: 13, lng: 14, alt: 15},+					{lat: 16, lng: 17, alt: 18}+				]+			];+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j]).to.eql(expected[i][j]);+				}+			}+		});+	});++	describe("#latLngToCoords", function () {+		it("returns an array of coordinates (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0));+			expect(coords).to.eql([0, 0]);+		});++		it("returns an array of coordinates and altitude (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0, 0));+			expect(coords).to.eql([0, 0, 0]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123, 1.123]);+		});+	});

ok yeah thats true... test code is just code that can have logical or syntax errors

phloose

comment created time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 027aafa16452c5e63ded4fd0b005b7f5f7b341c6

Rework coordsToLatLng test

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha ef4283bf6b2ba6f58726397d554cc8eb189258ce

Combine lng-lat and lng-lat-alt test cases

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha d14f489aaa2c685c24d3d6041313481634e66b04

Combine lng-lat and lng-lat-alt test cases

view details

push time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.GeoJSON functions", function () { 	});  	describe("#latLngsToCoords", function () {-		it("returns a multidimensional array of coordinates", function () {-			var coords = L.GeoJSON.latLngsToCoords([L.latLng(2, 1), L.latLng(4, 3)]);-			expect(coords).to.eql([[1, 2], [3, 4]]);+		it("returns a multidimensional array of coordinates (latitude, longitude, altitude)", function () {+			var latLngs = [L.latLng(2, 1, 3), L.latLng(5, 4, 6)];+			var coords = L.GeoJSON.latLngsToCoords(latLngs);+			expect(coords).to.eql([[1, 2, 3], [4, 5, 6]]);

Ok will change that. Unfortunatly the more shorter form you proposed (which i would prefer)

it("returns a multidimensional array of coordinates", function () {
			expect(L.GeoJSON.latLngsToCoords)
				.withArgs([L.latLng(2, 1), L.latLng(4, 3)])
				.to.eql([[1, 2], [3, 4]]);
			expect(L.GeoJSON.latLngsToCoords)
				.withArgs([L.latLng(2, 1, 3), L.latLng(5, 4, 6)])
				.to.eql([[1, 2, 3], [4, 5, 6]]);

seems to only work for catching exceptions. It cannot test against a returned value.

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j] instanceof L.LatLng).to.be(true);+				}+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () {+			const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);+			const expected = [+				{lat: 2, lng: 3, alt: 4},+				{lat: 5, lng: 6, alt: 7},+				{lat: 8, lng: 9, alt: 10}+			];+			for (var i = 0; i < latLngs.length; i++) {+				expect(latLngs[i]).to.eql(expected[i]);+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () {+			const coords = [+				[[1, 2, 3], [4, 5, 6]],+				[[12, 13, 14], [15, 16, 17]]+			];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);+			const expected = [+				[+					{lat: 2, lng: 3, alt: 4},+					{lat: 5, lng: 6, alt: 7}+				],+				[+					{lat: 13, lng: 14, alt: 15},+					{lat: 16, lng: 17, alt: 18}+				]+			];+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j]).to.eql(expected[i][j]);+				}+			}+		});+	});++	describe("#latLngToCoords", function () {+		it("returns an array of coordinates (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0));+			expect(coords).to.eql([0, 0]);+		});++		it("returns an array of coordinates and altitude (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0, 0));+			expect(coords).to.eql([0, 0, 0]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123, 1.123]);+		});+	});

btw, test may fail not only because of expect

huh? what do you mean exactly with that? programming errors? just curious...

phloose

comment created time in a month

pull request commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

Should i squash all commits when you approve this or is it done automatically?

phloose

comment created time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 3aeffb1a04b6f50d86b45f4dcecf38196b811143

Only use (lat, lng, alt) cases in general coords- or latLng-tests

view details

push time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j] instanceof L.LatLng).to.be(true);+				}+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () {+			const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);+			const expected = [+				{lat: 2, lng: 3, alt: 4},+				{lat: 5, lng: 6, alt: 7},+				{lat: 8, lng: 9, alt: 10}+			];+			for (var i = 0; i < latLngs.length; i++) {+				expect(latLngs[i]).to.eql(expected[i]);+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () {+			const coords = [+				[[1, 2, 3], [4, 5, 6]],+				[[12, 13, 14], [15, 16, 17]]+			];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);+			const expected = [+				[+					{lat: 2, lng: 3, alt: 4},+					{lat: 5, lng: 6, alt: 7}+				],+				[+					{lat: 13, lng: 14, alt: 15},+					{lat: 16, lng: 17, alt: 18}+				]+			];+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j]).to.eql(expected[i][j]);+				}+			}+		});+	});++	describe("#latLngToCoords", function () {+		it("returns an array of coordinates (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0));+			expect(coords).to.eql([0, 0]);+		});++		it("returns an array of coordinates and altitude (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0, 0));+			expect(coords).to.eql([0, 0, 0]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123, 1.123]);+		});+	});

As for this case, I feel that [lat, lng] is kind of special case of general [lat, lng, alt].

I think its more the general case to only have [lat, lng], as until now i have never had any GeoJSON dataset that also had altitude values.

having too many discrete tests can be a bit confusing

Well, in this case the test description clearly tells what is tested, so i don't see any confusion here to be honest :)

we do not lose anything if we put two similar tests together, as when test fails - we see where it fails (exact line).

Sure you are right, but with two different cases you instantly know which of the test failed by description. You wouldn't have to read line numbers. But yeah, you are right this is a matter of taste. Personally i prefer to put such cases into seperate tests, as for me DRY doesn't necessarily count in tests. I will put those two tests into one.

phloose

comment created time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 419ea79a09f4903eae1527656ed0dc0892e6ed7d

Apply review suggestions

view details

push time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {

tried flat, doesnt work. Using forEach two times now.

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j] instanceof L.LatLng).to.be(true);+				}+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () {+			const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);+			const expected = [+				{lat: 2, lng: 3, alt: 4},+				{lat: 5, lng: 6, alt: 7},+				{lat: 8, lng: 9, alt: 10}+			];+			for (var i = 0; i < latLngs.length; i++) {+				expect(latLngs[i]).to.eql(expected[i]);+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () {+			const coords = [+				[[1, 2, 3], [4, 5, 6]],+				[[12, 13, 14], [15, 16, 17]]+			];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);+			const expected = [+				[+					{lat: 2, lng: 3, alt: 4},+					{lat: 5, lng: 6, alt: 7}+				],+				[+					{lat: 13, lng: 14, alt: 15},+					{lat: 16, lng: 17, alt: 18}+				]+			];+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j]).to.eql(expected[i][j]);+				}+			}+		});+	});++	describe("#latLngToCoords", function () {+		it("returns an array of coordinates (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0));+			expect(coords).to.eql([0, 0]);+		});++		it("returns an array of coordinates and altitude (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0, 0));+			expect(coords).to.eql([0, 0, 0]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123]);+		});++		it("returns an array of coordinates with given precision (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(+				1.123456, 1.123456, 1.123456+			), 3);+			expect(coords).to.eql([1.123, 1.123, 1.123]);+		});+	});

But why combine them? They are two different cases.

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});

yeah a stupid copy/paste failure... but this tests is for the case when you use lon, lat and alt

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j] instanceof L.LatLng).to.be(true);+				}+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () {+			const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);+			const expected = [+				{lat: 2, lng: 3, alt: 4},+				{lat: 5, lng: 6, alt: 7},+				{lat: 8, lng: 9, alt: 10}+			];+			for (var i = 0; i < latLngs.length; i++) {+				expect(latLngs[i]).to.eql(expected[i]);+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () {+			const coords = [+				[[1, 2, 3], [4, 5, 6]],+				[[12, 13, 14], [15, 16, 17]]+			];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);+			const expected = [+				[+					{lat: 2, lng: 3, alt: 4},+					{lat: 5, lng: 6, alt: 7}+				],+				[+					{lat: 13, lng: 14, alt: 15},+					{lat: 16, lng: 17, alt: 18}+				]+			];+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j]).to.eql(expected[i][j]);+				}+			}+		});+	});++	describe("#latLngToCoords", function () {+		it("returns an array of coordinates (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0));+			expect(coords).to.eql([0, 0]);+		});++		it("returns an array of coordinates and altitude (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0, 0));

sure, that makes sense!

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j] instanceof L.LatLng).to.be(true);+				}+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () {+			const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);+			const expected = [+				{lat: 2, lng: 3, alt: 4},+				{lat: 5, lng: 6, alt: 7},+				{lat: 8, lng: 9, alt: 10}+			];+			for (var i = 0; i < latLngs.length; i++) {+				expect(latLngs[i]).to.eql(expected[i]);+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () {+			const coords = [+				[[1, 2, 3], [4, 5, 6]],+				[[12, 13, 14], [15, 16, 17]]+			];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);+			const expected = [+				[+					{lat: 2, lng: 3, alt: 4},+					{lat: 5, lng: 6, alt: 7}+				],+				[+					{lat: 13, lng: 14, alt: 15},+					{lat: 16, lng: 17, alt: 18}+				]+			];+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j]).to.eql(expected[i][j]);+				}+			}

I didn't know that you can check nested structures this way (which is really cool btw....)

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {

ok, i just looked at the methods implementation and there it returns null, even though it is not mentioned in the doc string. Or what do you mean with specs? Strictly speaking i would also have to remove this one https://github.com/Leaflet/Leaflet/pull/7147#discussion_r429548120 as it is also not mentioned in the doc string.

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);

Yeah true! Just saw that too late and then it was pushed. I wanted to wait for a review first...

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON geometry (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer(geometry);+				expect(layer instanceof L.Layer).to.be(true);+			});+		});++		it("throws an error if feature is an invalid GeoJSON object", function () {+			expect(function () {+				L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: {+						type: "invalid",+						coordinates: [0, 0]+					}+				});+			}).to.throwError("Invalid GeoJSON object.");+		});++		it("returns null if feature does not have a geometry property", function () {+			const ret = L.GeoJSON.geometryToLayer({type: "Feature"});+			expect(ret).to.be(null);+		});++		it("creates a Layer using pointToLayer option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: point,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			expect(layer instanceof L.Circle).to.be(true);+			expect(layer.options.radius).to.be(100);+		});++		it("creates a Layer using pointToLayer option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: multiPoint,+				properties: {radius: 100}+			}, {+				pointToLayer: customPointToLayer+			});+			Object.keys(layer._layers).forEach(function (id) {+				expect(layer._layers[id] instanceof L.Circle).to.be(true);+				expect(layer._layers[id].options.radius).to.be(100);+			});+		});++		it("creates a Layer using coordsToLatLng option (Point)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "Point",+					coordinates: [1, 2, 3]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			expect(layer._latlng).to.eql({lat: 3, lng: 2, alt: 4});+		});++		it("creates a Layer using coordsToLatLng option (MultiPoint)", function () {+			const layer = L.GeoJSON.geometryToLayer({+				type: "Feature",+				geometry: {+					type: "MultiPoint",+					coordinates: [+						[1, 2, 3], [4, 5, 6]+					]+				}+			}, {+				coordsToLatLng: customCoordstoLatLng+			});+			const expected = [+				{lat: 3, lng: 2, alt: 4},+				{lat: 6, lng: 5, alt: 7}+			];+			const ids = Object.keys(layer._layers);+			for (var i = 0; i < ids.length; i++) {+				expect(layer._layers[ids[i]]._latlng).to.eql(expected[i]);+			}+		});+	});++	describe("#coordsToLatLng", function () {+		it("creates a LatLng object given longitude and latitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(undefined);+		});++		it("creates a LatLng object given longitude, latitude and altitude", function () {+			const latlng = L.GeoJSON.coordsToLatLng([0, 0, 0]);+			expect(latlng instanceof L.LatLng).to.be(true);+			expect(latlng.lat).to.be(0);+			expect(latlng.lat).to.be(0);+			expect(latlng.alt).to.be(0);+		});+	});++	describe("#coordsToLatLngs", function () {++		function customCoordsToLatLng(coords) {+			return new L.LatLng(coords[0] + 1, coords[1] + 1, coords[2] + 1);+		}++		it("creates a multidimensional array of LatLngs", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([[0, 0], [1, 1], [2, 2]]);+			expect(latLngs.length).to.be(3);+			latLngs.forEach(function (latLng) {+				expect(latLng instanceof L.LatLng).to.be(true);+			});+		});++		it("creates a multidimensional array of LatLngs (levelsDeep=1)", function () {+			const latLngs = L.GeoJSON.coordsToLatLngs([+				[[0, 0], [1, 1], [2, 2]],+				[[4, 4], [5, 5], [6, 6]]+			], 1);+			expect(latLngs.length).to.be(2);+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j] instanceof L.LatLng).to.be(true);+				}+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng", function () {+			const coords = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 0, customCoordsToLatLng);+			const expected = [+				{lat: 2, lng: 3, alt: 4},+				{lat: 5, lng: 6, alt: 7},+				{lat: 8, lng: 9, alt: 10}+			];+			for (var i = 0; i < latLngs.length; i++) {+				expect(latLngs[i]).to.eql(expected[i]);+			}+		});++		it("creates a multidimensional array of LatLngs with custom coordsToLatLng (levelDeep=1)", function () {+			const coords = [+				[[1, 2, 3], [4, 5, 6]],+				[[12, 13, 14], [15, 16, 17]]+			];+			const latLngs = L.GeoJSON.coordsToLatLngs(coords, 1, customCoordsToLatLng);+			const expected = [+				[+					{lat: 2, lng: 3, alt: 4},+					{lat: 5, lng: 6, alt: 7}+				],+				[+					{lat: 13, lng: 14, alt: 15},+					{lat: 16, lng: 17, alt: 18}+				]+			];+			for (var i = 0; i < latLngs.length; i++) {+				for (var j = 0; j < latLngs[i].length; j++) {+					expect(latLngs[i][j]).to.eql(expected[i][j]);+				}+			}+		});+	});++	describe("#latLngToCoords", function () {+		it("returns an array of coordinates (longitude, latitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0));+			expect(coords).to.eql([0, 0]);+		});++		it("returns an array of coordinates and altitude (longitude, latitude, altitude)", function () {+			const coords = L.GeoJSON.latLngToCoords(new L.LatLng(0, 0, 0));

I just thought it would be more readable and since it doesnt matter if these are real wgs84 coordinates or just cartesian i used the most simple ones. Will change that!

phloose

comment created time in a month

Pull request review commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

 describe("L.LayerGroup#toGeoJSON", function () { 		}); 	}); });++describe("L.GeoJSON functions", function () {+	describe("#geometryToLayer", function () {+		const point = {+			type: "Point",+			coordinates: [0, 0]+		};+		const multiPoint  = {+			type: "MultiPoint",+			coordinates: [+				[0, 0], [10, 10]+			]+		};+		const line =  {+			type: "LineString",+			coordinates: [+				[0, 0], [10, 10], [20, 20]+			]+		};+		const multiLine = {+			type: "MultiLineString",+			coordinates: [+				[[10, 10], [20, 20], [30, 30]],+				[[50, 50], [60, 60], [70, 70]]+			]+		};+		const polygon = {+			type: "Polygon",+			coordinates: [+				[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]+			]+		};+		const multiPolygon = {+			type: "MultiPolygon",+			coordinates: [+				[+					[[30, 20], [45, 40], [10, 40], [30, 20]]+				],+				[+					[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]+				]+			]+		};+		const geometryCollection  = {+			type: "GeometryCollection",+			geometries: [+				{+					type: "Point",+					coordinates: [0, 0]+				},+				{+					type: "LineString",+					coordinates: [+						[10, 10], [20, 20]+					]+				}+			]+		};++		function customPointToLayer(geojsonPoint, latLng) {+			return new L.Circle(latLng, {+				radius: geojsonPoint.properties.radius+			});+		}++		function customCoordstoLatLng(coords) {+			return new L.LatLng(coords[1] + 1, coords[0] + 1, coords[2] + 1);+		}++		[+			point, line, polygon,+			multiPoint, multiLine, multiPolygon,+			geometryCollection+		].forEach(function (geometry) {+			it("creates a Layer from a GeoJSON feature (type='" + geometry.type + "')", function () {+				const layer = L.GeoJSON.geometryToLayer({+					type: "Feature",+					geometry: geometry+				});+				expect(layer instanceof L.Layer).to.be(true);

why is that a better way? i am just curious

phloose

comment created time in a month

pull request commentLeaflet/Leaflet

Tests for L.GeoJSON static functions

the pipeline seems to still be running but when clicking on details its shows up as finished...

phloose

comment created time in a month

issue commentLeaflet/Leaflet

Tests for GeoJSON functions required

@johnd0e i opened a ready-for-review pull request that adds the respective tests.

johnd0e

comment created time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha cdf298bf7e5070285148d3d666aabf446784965f

Add tests for asFeature

view details

push time in a month

push eventphloose/Leaflet

johnd0e

commit sha 9b0d7c2a7023e6a83222d96febaee74880601ad8

Update dev dependencies, fix most of vulnerabilities (#7133) * Update rollup-plugin-git-version to ^0.3.1 * Update uglify-js to ^3.9.2 * Update git-rev-sync to ^2.0.0 * Update ssri to ^8.0.0 * Update rollup to ^0.59.4 (latests version with support of IE 8) Remove Object.freeze hack, use rollup's `output.freeze` option instead * Update eslint to ^5.16.0 And fix a couple of warnings. Ref: https://eslint.org/docs/user-guide/migrating-to-5.0.0#eslint-recommended-changes https://eslint.org/docs/user-guide/migrating-to-5.0.0#deprecated-globals * Update eslint to ^6.8.0 Ref: https://eslint.org/docs/user-guide/migrating-to-6.0.0#eslint-recommended-changes

view details

mi-v

commit sha 838587dff062af1af89c2ae7ca60e451e0e4de26

L.Marker shadowPane doc fix (#7135)

view details

Philipp Loose

commit sha baf8e9e1a0662030370775fe7525dd0aa83293fa

Add .vscode to gitignore

view details

Philipp Loose

commit sha 58e9524ea87dc823aa1ce99076bf705bba82743f

Add test for successful layer creation with L.GeoJSON.geometryToLayer

view details

Philipp Loose

commit sha 74770a7f61530d5589b4fd4c42bde665f1e02467

Add test for error case when using an invalid GeoJSON object in L.GeoJSON.geometryToLayer

view details

Philipp Loose

commit sha 3aed7a9c772a101001b7aea4580557cfae39bdaa

Add test for returning null when input feature does not have a geometry property

view details

Philipp Loose

commit sha c7c2b1e8b7d55432d72cfa4dd17a823114827e87

Add test for using custom pointToLayer function with geometryToLayer and point geometries

view details

Philipp Loose

commit sha aa488efe00fa8264127427881293cbc45f159121

Add test for custom coordsToLatLng function with geometryToLayer

view details

Philipp Loose

commit sha d3ec6bfe15112cc03331a43b1d47c782641cd3ce

Add tests for coordsToLatLng

view details

Philipp Loose

commit sha a4a1caf0b3a3e8d1761d0e4c61ff1b81597b7c9f

Add tests for coordsToLatLngs

view details

Philipp Loose

commit sha 3d85364251338758fdebc84f39848fed2d53a64a

Add tests for latLngToCoords

view details

Philipp Loose

commit sha db04e06518ffd71baf0e45bf15e61052744f692c

Add tests for latLngsToCoords

view details

Philipp Loose

commit sha ca6d41530b012ad03c8965001268e49460d288cd

Add tests for asFeature

view details

push time in a month

push eventphloose/Leaflet

Álvaro Mondéjar

commit sha 19da01346d8f69b075d02d9b714bbf5a0f2c03e5

Fix DivOverlay.getElement function documentation (#7111)

view details

johnd0e

commit sha e7a5c6ffbfd50ac9ee8edf54ceb00ef044f38166

Add more browser profiles and fix some tests (#7115) * MapSpec.js: fix: mocked function must be restored Otherwise it will break crs.project test in CRSSpec.js * MapSpec.js: skip broken test crsMock.verify() call is mandatory here, but it shows that crs.project is never called, thus the test is not ever valid. * MapSpec.js: fix non-valid test Revert 50a4845a785fe738213b6f305f51a7e8023fc888 and 1b1d96a4c467119ae45ace57b7724209a1f65cc1, and refactor a bit (rather cosmetical changes) * MapSpec.js: fix more tests Refactor before/afterEach hooks for more careful setup/cleanup. Fix some non-valid tests: * #remove - "undefines container._leaflet" - "unbinds events" * #removeLayer - "when the last tile layer on a map is removed" - "when a tile layer is removed from a map and it had greater zoom level coverage than the remainding layer" - "when a tile layer is removed from a map it and it had lesser or the sa,e zoom level coverage as the remainding layer(s)" * GridLayerSpec.js: fix some tests Refactor before/afterEach hooks for more careful setup/cleanup. Fix some non-valid tests: * "when a tilelayer is added to a map that already has a tilelayer" * spec/suites/**: refactor for more careful setup/cleanup Refactor before/afterEach hooks Other minor changes * SpecHelper.js: rename skipIn(non)Phantom to skipIf(No)3d ..to make things more clear Remove unused helper functions * Update testing deps sinon.js: left on 7.5.0 (latest still working on PhantomJS) karma-rollup-preprocessor: left on 6.1.2 (latest still supporting rollup < 1.0.0) * CRSSpec.js: workaround round-off error in Chrome L.CRS.zoom(L.CRS.scale(2.5)) results 2.4999999999999996 in Chrome Note: comparing floating point numbers properly is hard, e.g. see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ * Fix touch tests failing in Chrome * karma.conf.js: add custom Chrome config to make some tests pass npm run test-nolint -- --browsers Chrome1280x1024 * spec/.eslintrc: do not forbid no-unused-vars rule * spec/.eslintrc: do not forbid more rules no-extend-native no-irregular-whitespace no-shadow * Add karma-edge-launcher * Add karma-ie-launcher Some test fails atm, see log: > karma start ./spec/karma.conf.js "--browsers" "IE" ................................................................................ ..... WARN: 'Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.', undefined ................................................................................ ................................................................................ ............................................................... IE 11.0 (Windows 10) ImageOverlay _image when loaded should raise the load event FAILED TypeError: Argument not optional at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:74:5) IE 11.0 (Windows 10) ImageOverlay _image when load fails should raise the error event FAILED TypeError: Argument not optional at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:83:5) IE 11.0 (Windows 10) ImageOverlay _image when load fails should change the image to errorOverlayUrl FAILED TypeError: Argument not optional at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:88:5) .. IE 11.0 (Windows 10) ImageOverlay #setZIndex should update the z-index of the image if it has allready been added to the map FAILED Error: expected 1 to equal '1' at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:111:4) IE 11.0 (Windows 10) ImageOverlay #setZIndex should set the z-index of the image when it is added to the map FAILED Error: expected 10 to equal '10' at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:121:4) IE 11.0 (Windows 10) ImageOverlay #setZIndex should use the z-index specified in options FAILED Error: expected 20 to equal '20' at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:127:4) ........................................................................ IE 11.0 (Windows 10) Marker.Drag drag in CSS scaled container drags a marker with mouse, compensating for CSS scale FAILED expected 0 to be within -50..-30 (node_modules/expect.js/index.js:102) ................................................................................ ........................................................... WARN: 'Deprecated use of _flat, please use L.LineUtil.isFlat instead.' . WARN: 'Deprecated use of _flat, please use L.LineUtil.isFlat instead.' .......................................................................... 05 2020 15:25:48.917:WARN [web-server]: : /000 05 2020 15:25:48.938:WARN [web-server]: : /000 ...... .. IE 11.0 (Windows 10) Map #invalidateSize pans by the right amount when growing in 1px increments FAILED Error: expected 0 to equal 1 at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/map/MapSpec.js:649:4) IE 11.0 (Windows 10) Map #invalidateSize pans by the right amount when shrinking in 1px increments FAILED Error: expected 0 to equal -1 at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/map/MapSpec.js:667:4) .. IE 11.0 (Windows 10) Map #invalidateSize emits a move event if the size has changed FAILED Error: expected false to be truthy at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5) at Anonymous function (node_modules/expect.js/index.js:499:7) at Anonymous function (spec/suites/map/MapSpec.js:700:4) IE 11.0 (Windows 10) Map #invalidateSize emits a moveend event if the size has changed FAILED Error: expected false to be truthy at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5) at Anonymous function (node_modules/expect.js/index.js:499:7) at Anonymous function (spec/suites/map/MapSpec.js:710:4) IE 11.0 (Windows 10) Map #invalidateSize debounces the moveend event if the debounceMoveend option is given FAILED Error: expected false to be truthy at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5) at Anonymous function (node_modules/expect.js/index.js:499:7) at Anonymous function (spec/suites/map/MapSpec.js:724:4) IE 11.0 (Windows 10) Map #invalidateSize correctly adjusts for new container size when view is set during map initialization (#6165) FAILED Error: expected 0 to equal 100 at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (spec/suites/map/MapSpec.js:745:4) ................ IE 11.0 (Windows 10) Map #fitBounds after layers set Snaps to a number after adding tile layer FAILED Error: Access is denied. at createTile (src/Leaflet.js:11698:3) at _addTile (src/Leaflet.js:11433:3) at _update (src/Leaflet.js:11330:5) at _setView (src/Leaflet.js:11191:5) at _resetView (src/Leaflet.js:11146:3) at onAdd (src/Leaflet.js:10784:3) at _layerAdd (src/Leaflet.js:6580:3) at Events.fire (src/Leaflet.js:588:6) at _resetView (src/Leaflet.js:4184:4) at setView (src/Leaflet.js:3181:3) .............................. IE 11.0 (Windows 10) Map.Drag mouse events in CSS scaled container change the center of the map, compensating for CSS scale FAILED expected 31.952162238024975 to be within 21.943..21.9431 (node_modules/expect.js/index.js:102) IE 11.0 (Windows 10) Map.Drag touch events change the center of the map FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10) Map.Drag touch events does not change the center of the map when finger is moved less than the drag threshold FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10) Map.Drag touch events reset itself after touchend FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) ............. IE 11.0 (Windows 10) Map.TouchZoom Increases zoom when pinching out FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10) Map.TouchZoom Decreases zoom when pinching in FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10): Executed 685 of 688 (20 FAILED) (skipped 3) (25.993 secs / 22.211 secs) * karma.conf.js: additional Firefox configs - FirefoxPointer - FirefoxTouch - FirefoxPointerTouch * .travis.yml: run CI tests with different Firefox configs Use FirefoxHeadless * karma.conf.js: change reporter to default ('progress') Because 'dots' is confusing when mixed up with different warnings. But for CI script 'dots' fits better due to travis-ci log qualities. * .travis.yml: run CI tests with Chrome too

view details

johnd0e

commit sha ec35ab52f66c191f7c855583354722c40dcdf239

GridLayer: fix _updateLevels and _removeTilesAtZoom (#7123) Because of particular quality of `for ... in` loop, type of `z` is 'string'. Thus condition `z === zoom` never met in _updateLevels. Considering wrong arg type, _removeTilesAtZoom also never had any action. Cleaner solution would be to iterate `Object.keys()` instead, but it is available only since IE 9.

view details

johnd0e

commit sha 9b0d7c2a7023e6a83222d96febaee74880601ad8

Update dev dependencies, fix most of vulnerabilities (#7133) * Update rollup-plugin-git-version to ^0.3.1 * Update uglify-js to ^3.9.2 * Update git-rev-sync to ^2.0.0 * Update ssri to ^8.0.0 * Update rollup to ^0.59.4 (latests version with support of IE 8) Remove Object.freeze hack, use rollup's `output.freeze` option instead * Update eslint to ^5.16.0 And fix a couple of warnings. Ref: https://eslint.org/docs/user-guide/migrating-to-5.0.0#eslint-recommended-changes https://eslint.org/docs/user-guide/migrating-to-5.0.0#deprecated-globals * Update eslint to ^6.8.0 Ref: https://eslint.org/docs/user-guide/migrating-to-6.0.0#eslint-recommended-changes

view details

mi-v

commit sha 838587dff062af1af89c2ae7ca60e451e0e4de26

L.Marker shadowPane doc fix (#7135)

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 6e270877bd5a5a47bfed0d8c390fa685a35240bc

Add tests for asFeature

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha e2bc4a98d7bbb8914920435521b31ed17c35bcab

Add tests for latLngsToCoords

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 37b8e21c1528492a6418e7b33bf64101b08fd96a

Add tests for latLngToCoords

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 9f7e94b93ad17b186e1b030ccb0649880390db3f

Add tests for coordsToLatLngs

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 73d6c608a0a6243a87e6e631c103a39acc0cb57c

Add tests for coordsToLatLng

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha ffb8d35ddc0136953a27f80074d4348334e95a68

Add tests for coordsToLatLng

view details

push time in a month

push eventphloose/Leaflet

Philipp Loose

commit sha 58fea4a34672847715d1121d257aaf16c82fd3dc

Add test for custom coordsToLatLng function with geometryToLayer

view details

push time in a month

issue commentpysal/esda

G_Local returns unexpectedly low z_sim for what should be a hotspot

Ok thank you, i think we can close this now!

phloose

comment created time in 2 months

issue commentpysal/esda

G_Local returns unexpectedly low z_sim for what should be a hotspot

At first i thought this counterintuitive result might be due to the more complicated neighbor situation that is defined by the Elbe. But then i thought regardless of that one specific neighbor situation to the lower left Hamburg should be still significantly outstanding with regard to the other neighbors that share a boundary on the other sides. I never tested it the way you did now to be honest...

Did you use the QGIS plugin i mentioned in the first post? It uses an old version of PySAL that "works" correctly and shows Hamburg as a hotspot as one would expect with such a high number of cases. But as mentioned in https://github.com/pysal/esda/issues/112#issuecomment-614749078 this version should not be used anymore.

phloose

comment created time in 2 months

issue commentpysal/esda

G_Local returns unexpectedly low z_sim for what should be a hotspot

@sjsrey A friendly reminder :) Could you find anything, that would explain the observations?

phloose

comment created time in 2 months

push eventphloose/Leaflet

Philipp Loose

commit sha e1707cc84ec3e17e82a17d75cfec538f6824811e

Add test for using custom pointToLayer function with geometryToLayer and point geometries

view details

push time in 2 months

push eventphloose/Leaflet

Philipp Loose

commit sha 0410c6c6bfe6bbf9d531fa948ce64f726cb2431f

Add test for using custom pointToLayer function with geometryToLayer and point geometries

view details

push time in 2 months

push eventphloose/Leaflet

Philipp Loose

commit sha 81fc9cfb3eec66926db045b36660e62aa88858ee

Add test for using custom pointToLayer function with geometryToLayer and point geometries

view details

push time in 2 months

delete branch phloose/Leaflet

delete branch : tests-for-geojson-functions-Leaflet#7099

delete time in 2 months

PR opened Leaflet/Leaflet

WIP: Tests for L.GeoJSON static functions

Attempts to write the required tests for the L.GeoJSON static functions mentioned in #7099.

+103 -0

0 comment

2 changed files

pr created time in 2 months

create barnchphloose/Leaflet

branch : tests-for-geojson-static-functions

created branch time in 2 months

push eventphloose/Leaflet

Álvaro Mondéjar

commit sha 19da01346d8f69b075d02d9b714bbf5a0f2c03e5

Fix DivOverlay.getElement function documentation (#7111)

view details

johnd0e

commit sha e7a5c6ffbfd50ac9ee8edf54ceb00ef044f38166

Add more browser profiles and fix some tests (#7115) * MapSpec.js: fix: mocked function must be restored Otherwise it will break crs.project test in CRSSpec.js * MapSpec.js: skip broken test crsMock.verify() call is mandatory here, but it shows that crs.project is never called, thus the test is not ever valid. * MapSpec.js: fix non-valid test Revert 50a4845a785fe738213b6f305f51a7e8023fc888 and 1b1d96a4c467119ae45ace57b7724209a1f65cc1, and refactor a bit (rather cosmetical changes) * MapSpec.js: fix more tests Refactor before/afterEach hooks for more careful setup/cleanup. Fix some non-valid tests: * #remove - "undefines container._leaflet" - "unbinds events" * #removeLayer - "when the last tile layer on a map is removed" - "when a tile layer is removed from a map and it had greater zoom level coverage than the remainding layer" - "when a tile layer is removed from a map it and it had lesser or the sa,e zoom level coverage as the remainding layer(s)" * GridLayerSpec.js: fix some tests Refactor before/afterEach hooks for more careful setup/cleanup. Fix some non-valid tests: * "when a tilelayer is added to a map that already has a tilelayer" * spec/suites/**: refactor for more careful setup/cleanup Refactor before/afterEach hooks Other minor changes * SpecHelper.js: rename skipIn(non)Phantom to skipIf(No)3d ..to make things more clear Remove unused helper functions * Update testing deps sinon.js: left on 7.5.0 (latest still working on PhantomJS) karma-rollup-preprocessor: left on 6.1.2 (latest still supporting rollup < 1.0.0) * CRSSpec.js: workaround round-off error in Chrome L.CRS.zoom(L.CRS.scale(2.5)) results 2.4999999999999996 in Chrome Note: comparing floating point numbers properly is hard, e.g. see https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ * Fix touch tests failing in Chrome * karma.conf.js: add custom Chrome config to make some tests pass npm run test-nolint -- --browsers Chrome1280x1024 * spec/.eslintrc: do not forbid no-unused-vars rule * spec/.eslintrc: do not forbid more rules no-extend-native no-irregular-whitespace no-shadow * Add karma-edge-launcher * Add karma-ie-launcher Some test fails atm, see log: > karma start ./spec/karma.conf.js "--browsers" "IE" ................................................................................ ..... WARN: 'Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.', undefined ................................................................................ ................................................................................ ............................................................... IE 11.0 (Windows 10) ImageOverlay _image when loaded should raise the load event FAILED TypeError: Argument not optional at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:74:5) IE 11.0 (Windows 10) ImageOverlay _image when load fails should raise the error event FAILED TypeError: Argument not optional at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:83:5) IE 11.0 (Windows 10) ImageOverlay _image when load fails should change the image to errorOverlayUrl FAILED TypeError: Argument not optional at raiseImageEvent (spec/suites/layer/ImageOverlaySpec.js:66:4) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:88:5) .. IE 11.0 (Windows 10) ImageOverlay #setZIndex should update the z-index of the image if it has allready been added to the map FAILED Error: expected 1 to equal '1' at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:111:4) IE 11.0 (Windows 10) ImageOverlay #setZIndex should set the z-index of the image when it is added to the map FAILED Error: expected 10 to equal '10' at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:121:4) IE 11.0 (Windows 10) ImageOverlay #setZIndex should use the z-index specified in options FAILED Error: expected 20 to equal '20' at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/layer/ImageOverlaySpec.js:127:4) ........................................................................ IE 11.0 (Windows 10) Marker.Drag drag in CSS scaled container drags a marker with mouse, compensating for CSS scale FAILED expected 0 to be within -50..-30 (node_modules/expect.js/index.js:102) ................................................................................ ........................................................... WARN: 'Deprecated use of _flat, please use L.LineUtil.isFlat instead.' . WARN: 'Deprecated use of _flat, please use L.LineUtil.isFlat instead.' .......................................................................... 05 2020 15:25:48.917:WARN [web-server]: : /000 05 2020 15:25:48.938:WARN [web-server]: : /000 ...... .. IE 11.0 (Windows 10) Map #invalidateSize pans by the right amount when growing in 1px increments FAILED Error: expected 0 to equal 1 at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/map/MapSpec.js:649:4) IE 11.0 (Windows 10) Map #invalidateSize pans by the right amount when shrinking in 1px increments FAILED Error: expected 0 to equal -1 at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (node_modules/expect.js/index.js:69:13) at Anonymous function (spec/suites/map/MapSpec.js:667:4) .. IE 11.0 (Windows 10) Map #invalidateSize emits a move event if the size has changed FAILED Error: expected false to be truthy at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5) at Anonymous function (node_modules/expect.js/index.js:499:7) at Anonymous function (spec/suites/map/MapSpec.js:700:4) IE 11.0 (Windows 10) Map #invalidateSize emits a moveend event if the size has changed FAILED Error: expected false to be truthy at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5) at Anonymous function (node_modules/expect.js/index.js:499:7) at Anonymous function (spec/suites/map/MapSpec.js:710:4) IE 11.0 (Windows 10) Map #invalidateSize debounces the moveend event if the debounceMoveend option is given FAILED Error: expected false to be truthy at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.ok (node_modules/expect.js/index.js:115:5) at Anonymous function (node_modules/expect.js/index.js:499:7) at Anonymous function (spec/suites/map/MapSpec.js:724:4) IE 11.0 (Windows 10) Map #invalidateSize correctly adjusts for new container size when view is set during map initialization (#6165) FAILED Error: expected 0 to equal 100 at Assertion.prototype.assert (node_modules/expect.js/index.js:102:7) at Assertion.prototype.equal (node_modules/expect.js/index.js:216:5) at Anonymous function (spec/suites/map/MapSpec.js:745:4) ................ IE 11.0 (Windows 10) Map #fitBounds after layers set Snaps to a number after adding tile layer FAILED Error: Access is denied. at createTile (src/Leaflet.js:11698:3) at _addTile (src/Leaflet.js:11433:3) at _update (src/Leaflet.js:11330:5) at _setView (src/Leaflet.js:11191:5) at _resetView (src/Leaflet.js:11146:3) at onAdd (src/Leaflet.js:10784:3) at _layerAdd (src/Leaflet.js:6580:3) at Events.fire (src/Leaflet.js:588:6) at _resetView (src/Leaflet.js:4184:4) at setView (src/Leaflet.js:3181:3) .............................. IE 11.0 (Windows 10) Map.Drag mouse events in CSS scaled container change the center of the map, compensating for CSS scale FAILED expected 31.952162238024975 to be within 21.943..21.9431 (node_modules/expect.js/index.js:102) IE 11.0 (Windows 10) Map.Drag touch events change the center of the map FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10) Map.Drag touch events does not change the center of the map when finger is moved less than the drag threshold FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10) Map.Drag touch events reset itself after touchend FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) ............. IE 11.0 (Windows 10) Map.TouchZoom Increases zoom when pinching out FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10) Map.TouchZoom Decreases zoom when pinching in FAILED Object doesn't support this action (node_modules/prosthetic-hand/dist/prosthetic-hand.js:624) IE 11.0 (Windows 10): Executed 685 of 688 (20 FAILED) (skipped 3) (25.993 secs / 22.211 secs) * karma.conf.js: additional Firefox configs - FirefoxPointer - FirefoxTouch - FirefoxPointerTouch * .travis.yml: run CI tests with different Firefox configs Use FirefoxHeadless * karma.conf.js: change reporter to default ('progress') Because 'dots' is confusing when mixed up with different warnings. But for CI script 'dots' fits better due to travis-ci log qualities. * .travis.yml: run CI tests with Chrome too

view details

johnd0e

commit sha ec35ab52f66c191f7c855583354722c40dcdf239

GridLayer: fix _updateLevels and _removeTilesAtZoom (#7123) Because of particular quality of `for ... in` loop, type of `z` is 'string'. Thus condition `z === zoom` never met in _updateLevels. Considering wrong arg type, _removeTilesAtZoom also never had any action. Cleaner solution would be to iterate `Object.keys()` instead, but it is available only since IE 9.

view details

Philipp Loose

commit sha dbc3ad8b4168f46f3bb5fb5a33b6745e3835aef7

Add .vscode to gitignore

view details

Philipp Loose

commit sha 59df2d131203686515231856a70f952711d9a269

Add test for successful layer creation with L.GeoJSON.geometryToLayer

view details

Philipp Loose

commit sha c9ee29bd20ae491b85d9ef180911c3c53c9d2539

Add test for error case when using an invalid GeoJSON object in L.GeoJSON.geometryToLayer

view details

Philipp Loose

commit sha 9561212635bd874cec9a7277c588bb58f5ee7531

Add test for returning null when input feature does not have a geometry property

view details

push time in 2 months

create barnchphloose/Leaflet

branch : tests-for-geojson-functions-Leaflet#7099

created branch time in 2 months

issue commentjbaileyh/geogrid

Porting to python

@jbaileyh if you are interested: In the last days i worked on a first functional version that creates regular or hexagonal grids on the dev branch.

phloose

comment created time in 2 months

issue commentpysal/esda

G_Local returns unexpectedly low z_sim for what should be a hotspot

Thanks for responding so fast! I didn't want to be stressful!

phloose

comment created time in 2 months

issue commentpysal/esda

G_Local returns unexpectedly low z_sim for what should be a hotspot

With regard to the cases attribute (~4000) it is clearly outstanding from its neighborhood: All "significant" high neighbors of Hamburg have cases between ~170 and 500, which separates them clearly from the outer neighbors. But Hamburg with such a high value as center from the hotspot is not a hotspot?!

@sjsrey any new insights why this is behaving in such a counterintuitive way?

phloose

comment created time in 2 months

fork phloose/Leaflet

:leaves: JavaScript library for mobile-friendly interactive maps

https://leafletjs.com

fork in 2 months

issue commentpysal/esda

G_Local returns unexpectedly low z_sim for what should be a hotspot

Thank you very much for taking time to examine my observations! I'd also prefer the most up to date versions of PySAL.

But i am still wondering why Hamburg is not "marked" as a hotspot? With regard to the cases attribute (~4000) it is clearly outstanding from its neighborhood: All "significant" high neighbors of Hamburg have cases between ~170 and 500, which separates them clearly from the outer neighbors. But Hamburg with such a high value as center from the hotspot is not a hotspot?! So why does it get such a low z-score? Am i misunderstanding something with regard to how G* works? From my intuition it does not make sense that Hamburg is not a hotspot...

Another interesting finding is that the result from pysal when visualized look different than what geoda returns: pysal_issue_112

Again thanks for taking your time to investigate in my issue!

phloose

comment created time in 3 months

issue commentjbaileyh/geogrid

Porting to python

Thanks for your reply and willingness! Currently i am working out what the functions of your R package are doing in detail. You can watch the progress at https://gitlab.com/phloose/pyeac/. The development takes place in the dev branch.

phloose

comment created time in 3 months

issue commentpysal/esda

G_Local returns unexpectedly low z_sim for what should be a hotspot

Thanks! If you need that particular corona dataset from which i calculated the example z_sim values let me know!

phloose

comment created time in 3 months

issue openedpysal/esda

G_Local returns unexpectely low z_sim for what should be a hotspot

pysal: 2.1.0
pysal.explore.esda: 2.1.1
python: 3.8.2 from miniconda3
os: Pop!_OS/Ubuntu 19.10 but also applies to windows 10 1910

I have come across a weird issue while trying to use the pysal.explore.esda.G_Local implementation with permutations to find local hot-/coldspots in several datasets.

The computed z_sim for a features attribute that by natural expectation should be a hotspot (because has really high numbers compared to the near neighborhood and much higher difference to the more far neighborhood) is much to low. It feels like a pattern that especially features with very large attribute differences to its neighborhood get a low z_sim value. They are often remarkably framed by statistically significant values.

Then i also found a QGIS plugin for hotspot analysis which uses an old version of pysal (1.14.3). There the hotspot analysis works as expected and returns high z_sim values for expected hotspots (see below example for corona cases in Hamburg)

I compute the G_Local like so:

import fiona
import numpy as np
import shapely.geometry as sg
from libpysal.weights import Queen
from pysal.explore.esda import G_Local

with fiona.open("RKI_Corona_Landkreise.shp") as inp:
    features = list(inp)

y = np.array([feature["properties"]["cases"] for feature in features])
w = Queen.from_shapefile("RKI_Corona_Landkreise.shp")

np.random.seed(12345)
g = G_Local(y, w, star=True, transform="r", permutations=999)

For testing: The last dataset i used was from the german Robert-Koch-Insitut for the current status of the corona pandemic on county level in germany. I used the cases attribute and as there are several hotspots just by knowing from the media and by just comparing the numbers i expected especially Hamburg, Heinsberg and Köln as hotspots (there are some more in the southern part of germany but for brevity lets focus on the named). What is striking now is that these "hotspots from knowledge" are statistically not significant, despite they should be, but are framed by other statistically significant hotspots.

A numeric example for Hamburg (index 15 of z_sim array)

  • PySAL 1.14.3 returns z_sim 2.82 for Hamburg
  • PySAL 2.1.0/PySAL explore esda 2.1.1 returns z_sim -0.21 for Hamburg (!)

The Zs values are all equal only the z_sim values are really different

Another dataset i used is an official census dataset from 2011 on county level. There i used the attribute L_Nichtehe which gives the number of communities that are not marital (don't know if google translated this correctly...). Again i expected Hamburg, Berlin and its surroundings as hotspots as these are big cities where a lot of people are living in non-marital communities. There the same pattern like described above occurs, really high values from G_Local not "marked" as statistically significant are framed by higher values that are statistically significant.

My question is now, what changed in the getisord module or in the G_Local implementation for the calculation of simulated values? Is this a bug? Please test the datasets i linked with both versions and tell me if you can reproduce this (the corona dataset might have been updated but Hamburg should still be a hotspot). It should not be that two versions of G_Local return a different z_sim value by using the same underlying algorithm... At the moment i am a bit lost ....

created time in 3 months

issue commentdigidem/leaflet-side-by-side

Swiping between Featuregroups

@grobins @dhanesh1795 @havardl, although some posts are really old, i would suggest you to have a look at leaflet-splitmap (which is a fork of this repo) that adds changing the clipping of the layers panes and not only their containers.

Although not directly connected to this repo i want to help all who search for this functionality, because it took me almost a whole day to figure out how i can get this to work unitl i found this simple solution...

The following refers to leaflet-splitmap NOT leaflet-side-by-side:

Like @grobins i wanted to compare two layers. Per default layers like GeoJSON are put on the overlayPane. When you simply add two layers (say two GeoJSON layers of the same featuregroup but e.g. different time) they both will be added to the overlayPane. When the divider is used leaflet-splitmap will try to change the left_-/right_layers clip css property of the containing pane according to the position of the divider (see this line). When both layers are on the same overlayPane the changes made to the left pane are immediately overwritten by setting the right pane because they refer to the same pane. To overcome this you need to put your two featuregroups in different panes. You do this by first creating the respective map panes by calling map.createPane and then set the pane property in the options of the layer you want to use with splitmap. Here you can read more about panes.

The example is taken from the leaflet-splitmap repo and slightly changed:

var map = L.map('map').setView([53, 10.5], 13);

var osmLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap<\/a> contributors'
}).addTo(map);

map.createPane("splitmap_left")
map.createPane("splitmap_right")

var marker1 = L.circleMarker([53, 10.5], {radius: 50, pane: "splitmap_left", color: "red"}).addTo(map)
var marker2 = L.circleMarker([53, 10.5], {radius: 50, pane: "splitmap_right"}).addTo(map)

var splitMap = L.control.splitMap(marker1, marker2).addTo(map);

I hope i could help anyone who wants to use these really helpful plugins!

grobins

comment created time in 3 months

fork phloose/leaflet-side-by-side

A Leaflet control to add a split screen to compare two map overlays

http://lab.digital-democracy.org/leaflet-side-by-side/

fork in 3 months

fork phloose/leaflet-splitmap

A Leaflet control to compare two map layers

fork in 3 months

more