Chrome deprecated console.info some time ago.
Here's a workaround that will actually make you happier than with console.info :)
Keeping track of interesting places I put my feet on in the software development world.
Search This Blog
Sunday, June 21, 2020
Wednesday, January 29, 2020
Importing .shp (shape) GIS files into mySQL db
Steps to import SHP files exported from GIS systems, into mySQL db:
To import GIS data into mySQL, we need to translate the geometry GIS descriptions into sql statements.
This can be achieved by using the opensource shp2mysql utility, along with cygwin1.dll (both in the same folter)
After generating the .sql file, all is left to do is to import it into mysql. I did it using sqlyog: right click in the target database → Import → Execute SQL Script → select the .sql file generated above.
But before doing that, you might do the following:
The table name where the data will be imported is derived from the sql output file name. Make sure you rename it in the Create Table statement, accordingly.
I had to manually fix the .sql file, to overcome the following issues:
- shp2mysql will create two columns named ID. I renamed the 2nd one to _ID
- my shp2mysql execution generates a 3D representation of each point, and I did not find a 3D syntax for MULTILINESTRING. I ended up replacing all 0.000000000000000 occurrences in the sql file to blank spaces, to fix it.
- the generated sql file had a -1 SRS id for each generated gis representation in WKT. mySql stated -1 is invalid, we checked which SRS id was used in our other GIS dbs, figured out it was 0, then I replaced all occurrences of ,-1) with ,0) in my sql file.
- shp2mysql will generate the sql file using a deprecated mysql function, GeometryFromText. According to mysql documentation, it was deprecated in mySql 5.7.6. Since my machine has mySql 8, I renamed all occurrences of it to ST_GeomFromText:
GeomFromText() and GeometryFromText() are deprecated as of MySQL 5.7.6 and will be removed in a future MySQL release. Use ST_GeomFromText() and ST_GeometryFromText() instead.
Now the file is valid and free of errors, and you can proceed and run the Execute SQL Script described above.
Tuesday, December 24, 2019
Saturday, December 21, 2019
Singleton, Decorator and Command design patterns (well) explained with (good) examples
An article that stands out of google search first results. Worth checking!
https://www.freecodecamp.org/news/the-basic-designs-patterns-all-developers-need-to-know/
https://www.freecodecamp.org/news/the-basic-designs-patterns-all-developers-need-to-know/
Sunday, December 15, 2019
Create circle with google map api with mousemove event to enlarge / shrink area
function addCircle_new(lat, lng, radius, alreadyDrawn) {
function createCircle(lat, lng, radius) {
var coordinates = new google.maps.LatLng(lat, lng);
var options = {
strokeColor: '#910000',
strokeOpacity: 0.5,
strokeWeight: 1,
fillColor: '#FC7341',
fillOpacity: 0.35,
map: map,
center: coordinates,
radius: radius
};
// Add the circle for this city to the map.
circle = new google.maps.Circle(options);
return circle;
}
var circle;
if (alreadyDrawn) {
circle = createCircle(lat, lng, radius * 1000);
drawObject = circle;
pois.push(circle);
}
else {
//google.maps.event.removeListener(clickListener);
google.maps.event.addListenerOnce(map, 'click', function (x) {
//circle = createCircle(x.latLng.lat(), x.latLng.lng(), radius * 1000);
circle = createCircle(lat, lng, radius * 1000);
var clickEventParameters = x;
var mouseMoveEventParameters;
var mouseMove = google.maps.event.addListener(map, 'mousemove', function (y) {
mouseMoveEventParameters = y;
var xOffset = mouseMoveEventParameters.qa.x - clickEventParameters.qa.x;
var yOffset = mouseMoveEventParameters.qa.y - clickEventParameters.qa.y;
var radiusOffset = Math.sqrt(Math.pow(xOffset, 2) + Math.pow(yOffset, 2)) * 100000;
circle.setRadius(radiusOffset);
});
var dblClick = google.maps.event.addListener(map, 'dblclick', function (w) {
drawObject = circle;
google.maps.event.removeListener(mouseMove);
pois.push(circle);
//clickListener = google.maps.event.addListener(map, 'click', map_MouseClick);
});
});
}
}
function createCircle(lat, lng, radius) {
var coordinates = new google.maps.LatLng(lat, lng);
var options = {
strokeColor: '#910000',
strokeOpacity: 0.5,
strokeWeight: 1,
fillColor: '#FC7341',
fillOpacity: 0.35,
map: map,
center: coordinates,
radius: radius
};
// Add the circle for this city to the map.
circle = new google.maps.Circle(options);
return circle;
}
var circle;
if (alreadyDrawn) {
circle = createCircle(lat, lng, radius * 1000);
drawObject = circle;
pois.push(circle);
}
else {
//google.maps.event.removeListener(clickListener);
google.maps.event.addListenerOnce(map, 'click', function (x) {
//circle = createCircle(x.latLng.lat(), x.latLng.lng(), radius * 1000);
circle = createCircle(lat, lng, radius * 1000);
var clickEventParameters = x;
var mouseMoveEventParameters;
var mouseMove = google.maps.event.addListener(map, 'mousemove', function (y) {
mouseMoveEventParameters = y;
var xOffset = mouseMoveEventParameters.qa.x - clickEventParameters.qa.x;
var yOffset = mouseMoveEventParameters.qa.y - clickEventParameters.qa.y;
var radiusOffset = Math.sqrt(Math.pow(xOffset, 2) + Math.pow(yOffset, 2)) * 100000;
circle.setRadius(radiusOffset);
});
var dblClick = google.maps.event.addListener(map, 'dblclick', function (w) {
drawObject = circle;
google.maps.event.removeListener(mouseMove);
pois.push(circle);
//clickListener = google.maps.event.addListener(map, 'click', map_MouseClick);
});
});
}
}
Monday, December 9, 2019
Elasticsearch aggregation - show aggregations only + overcome default limitation of aggregated buckets
Elasticsearch aggregation - output showing only aggregated field + overcoming default limitation of aggregated values (in this case, set to 1000)
GET customer_success_reports/_search
{
"size":0,
"aggs" : {
"Country": {
"composite" : {
"size": 1000,
"sources" : [
{ "country": { "terms" : { "field": "Meta.GeoInfo.Country.keyword","missing_bucket": true } } }
]
}
}
}
}
size:0 -> makes the output show the aggregated buckets only instead of the whole documents
GET customer_success_reports/_search
{
"size":0,
"aggs" : {
"Country": {
"composite" : {
"size": 1000,
"sources" : [
{ "country": { "terms" : { "field": "Meta.GeoInfo.Country.keyword","missing_bucket": true } } }
]
}
}
}
}
size:0 -> makes the output show the aggregated buckets only instead of the whole documents
Tuesday, November 19, 2019
Subscribe to:
Posts (Atom)