forked from codeforspain/ds-codigos-postales
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e17ce08
commit 2d57f4b
Showing
6,302 changed files
with
503,425 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# User specific & automatically generated files # | ||
################################################# | ||
.idea/ | ||
|
||
# OS generated files # | ||
###################### | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
Icon? | ||
ehthumbs.db | ||
Thumbs.db | ||
*~ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "ds-codigos-postales", | ||
"title": "Dataset de Códigos Postales", | ||
"description": "Geometrías de todos los códigos postales de España, incluyendo los códigos INE de los municipios asociados", | ||
"sources": [ | ||
{ | ||
"name": "CNIG - Centro Nacional de Información Geográfica", | ||
"web": "http://centrodedescargas.cnig.es/CentroDescargas/" | ||
} | ||
], | ||
"contributors": [ | ||
{ | ||
"name": "Javier Escribano" | ||
}, | ||
{ | ||
"name": "Iñigo Flores" | ||
} | ||
], | ||
"resources": [ | ||
{ | ||
"name": "codigos_postales", | ||
"path": "data/codigos_postales.geojson", | ||
"format": "geojson", | ||
"mediatype": "application/json", | ||
"bytes": 159860385 | ||
} | ||
], | ||
"homepage": "", | ||
"version": "0.1.3", | ||
"license": "ODC-PDDL-1.0", | ||
"repository": "git://github.com/codeforspain/ds-codigos-postales.git", | ||
"last_updated": "2016-11-24" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Script | ||
|
||
Descarga y procesa shapefiles de Cartociudad y extrae las geometrías de los códigos postales a un único archivo geojson. | ||
|
||
## Modo de Uso | ||
|
||
### Descarga | ||
|
||
$ node download.js | ||
|
||
### Procesado | ||
|
||
$ node process.js | ||
|
||
|
||
## Requisitos | ||
|
||
* Node.js | ||
* GDAL/OGR | ||
|
||
La última versión de GDAL/OGR en UBUNTU se puede obtener de ppa:ubuntugis/ppa | ||
|
||
$ sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update | ||
$ sudo apt-get install gdal-bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* @fileOverview Crea shapefiles de codigos postales en formato ZIP a partir de los archivos que proporciona Cartociudad | ||
* @version 0.0.1 | ||
*/ | ||
|
||
var AdmZip = require('adm-zip'); | ||
var fs = require('fs'); | ||
var archiver = require('archiver'); | ||
var _ = require('underscore'); | ||
var async = require('async'); | ||
var request = require('request'); | ||
var glob = require("glob") | ||
var ogr2ogr = require('ogr2ogr'); | ||
|
||
// Constantes | ||
var BASEURL = 'http://centrodedescargas.cnig.es/CentroDescargas/downloadFile.do?seq='; | ||
var SOURCES_FOLDER = '../archive/'; | ||
var fileList = _.range(9082, 9130).concat(_.range(42602, 42606)); | ||
var extensions = ['dbf','prj','shp','shx','cpg']; | ||
|
||
|
||
// Elimina de la lista los archivos ya generados | ||
glob(SOURCES_FOLDER + "*.zip", {sync: true}).forEach(function(element){ | ||
id = parseInt(element.split(SOURCES_FOLDER)[1].split("-")[0]); | ||
if ((index = fileList.indexOf(id)) > -1){ | ||
fileList.splice(index, 1); | ||
} | ||
}) | ||
|
||
// Descarga y procesa de forma concurrente hasta 5 archivos | ||
async.mapLimit(fileList, 5, function(item, callback){ | ||
console.log("Descargando " + BASEURL + item); | ||
request({url:BASEURL + item, encoding:null}, function (error, response, body) { | ||
saveProvince(error, body, item); | ||
callback(error,body); | ||
}); | ||
}, function(err, results){ | ||
console.log('Terminado!'); | ||
}); | ||
|
||
|
||
/** | ||
* Procesa y graba a disco el shapefile en zip con los codigos postales | ||
* @param error | ||
* @param body | ||
* @param item | ||
*/ | ||
function saveProvince(error,body,item){ | ||
|
||
var archive = archiver('zip'); | ||
var sourceZip = new AdmZip(body); | ||
var zipEntries = sourceZip.getEntries(); // an array of ZipEntry records | ||
|
||
zipEntries.some(function(zipEntry) { | ||
if (zipEntry.isDirectory) { | ||
provincia = zipEntry.entryName.split("CARTOCIUDAD_CALLEJERO_")[1].slice(0,-1); | ||
return true; | ||
} | ||
}); | ||
|
||
var output = fs.createWriteStream(SOURCES_FOLDER + item + "-" + provincia + ".zip"); | ||
console.log("Generado " + provincia + ".zip"); | ||
archive.pipe(output); | ||
|
||
extensions.forEach(function(ext){ | ||
entry = sourceZip.getEntry('CODIGO_POSTAL.' + ext); | ||
archive.append(entry.getData(), { name: provincia + "." + ext }); | ||
}); | ||
|
||
archive.finalize(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.