failed conversion with TopoJSON - json

After installing topojson with sudo npm install -g topojson I am unable to convert neither a shapfile (.shp) nor a geojson file to a topojson file.
Alexanders-MacBook-Pro:topojson alexander$ geo2topo Parcel11_projected.geojson > Parcel11_topo.json
buffer.js:495
throw new Error('"toString()" failed');
^
Error: "toString()" failed
at Buffer.toString (buffer.js:495:11)
at Object.parse (native)
at ReadStream.<anonymous> (/usr/local/lib/node_modules/topojson/bin/geo2topo:107:46)
at emitNone (events.js:91:20)
at ReadStream.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Alexanders-MacBook-Pro:topojson alexander$ topojson -q 1e4 -o out.json --Parcel11Cert.shp
-bash: topojson: command not found
It seems that the code is executed in the first case but the geojson is too large to convert. In the second case, the command is not recognized.
I am using the following command line reference
Any idea what could be going wrong here?

Already answered in Large geoJSON to TopoJSON. Summary: File is too large to be processed by the js engine, error message is unfortunate.

Related

json nmp package not working

I am using json npm package to update package.json file.
Using following commands
json -f package.json -I -e this.dependencies.data-version=\"1.0.0.1\"
Getting following error message
undefined:2
this.dependencies.'data-version'="1.0.0.1"
^^^^^^^^^^
SyntaxError: Unexpected string
at new Function (<anonymous>)
at main (C:\Users\SEUser2\AppData\Roaming\npm\node_modules\json\lib\json.js:
1289:27)
at Object.<anonymous> (C:\Users\SEUser2\AppData\Roaming\npm\node_modules\jso
n\lib\json.js:1683:5)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
I observer that if field name contains '-' character if creates issue.
How to run above command escaping '-' character ?
The best way I've found to update outdated packages in the package.json is to use: npm-check
npm-check -u
Which will let you interactively update the packages you want to update.
Can you try using this.dependencies['data=version'] instead

Im unable to find the error with mysql code

I am newbie. i am not able to insert data from front end into mysql database. I am facing the problem at the time of insertion.
my index.js code
I'm storing the form details in a variable and trying to insert it into database
router.post('/signup',function(req,res,next) {
var item = req.body;
connection.connect(function(err){
var sql = "INSERT INTO details VALUES ? ";
connection.query(sql,[item]);
});
res.render('data' ,{items:item});
});
Error message
/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors
^
Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`name` = 'Gayathri', `pwd` = 'def'' at line 1
at Query.Sequence._packetToError (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14)
at Query.ErrorPacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
at Protocol._parsePacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:279:23)
at Parser.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
--------------------
at Protocol._enqueue (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Connection.query (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:208:25)
at Handshake._callback (/home/gayathri/jsonhbs/routes/index.js:46:14)
at Handshake.Sequence.end (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
at /home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:225:14
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jsonhbs#0.0.0 start: `node ./bin/www`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jsonhbs#0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/gayathri/.npm/_logs/2017-10-18T03_54_05_403Z-debug.log
That's not valid SQL syntax. You can't use a placeholder for a bunch of values like that, you must break them out individually:
connection.query(
"INSERT INTO details (name, pwd) VALUES (?,?)",
[ "Name", "Pwd" ]
);
Supplying all those conditions as a single placeholder has the effect of encapsulating them inside a string, which breaks the syntax.
IMPORTANT: Always hash your passwords, never use plain-text to store them. At the absolute least use Bcrypt which is specifically intended for passwords and not some high-speed hash like SHA1 or a compromised hash like MD5.
If you're using Node you probably want to at least consider using Passport which can do a lot of the heavy lifting for you, and plays nicely with other Node components.

Topojson command line -- stripping some geometries & ?mismatch? in external properties

EDIT/UPDATE -- I never figured out the error message, but new day, try again, this post helped: How to add properties to topojson file?
and the way to marry it was this, add a second NAME
topojson -o output.json --id-property=NAME,NAME -p -e counties.csv CountiesTopo.json
I have a nice topojson that shows all the counties in Georgia. It loads, displays fine. I converted it from .shp with shpescape.com
BUT! I want to blend it with some external properties, the graduation rate for each county as stored in a .csv. So I'm trying topojson at the command line.
GaCountiesTopo.json has a field called NAME; the data's capitalized.
counties.csv has a field called NAME; the data's capitalized.
I tried this:
topojson \
-o output.json \
-e counties.csv \
-- id-property=NAME \
-p \
-- CountiesTopo.json
And got this:
fs.js:427
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory 'NAME'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at inputJson (/usr/local/lib/node_modules/topojson/bin/topojson:218:30)
at pop (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:28:14)
at Object.q.defer (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:59:11)
at /usr/local/lib/node_modules/topojson/bin/topojson:164:5
at Array.forEach (native)
at Object.<anonymous> (/usr/local/lib/node_modules/topojson/bin/topojson:163:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
No such file or directory 'NAME', eh? Is this a syntax error on my part? Or is it possible that the field name 'NAME' for some reason isn't matching up one-to-one? Or maybe somewhere there's a lonely county in the .json that doesn't have a counterpart in the .csv, like maybe I'm trying to match Screven with Scerven? 159 counties!
Hmm .. maybe my input, CountiesTopo.json has gotten screwed up? So, let's try this, just to see what happens:
-o output.json \
-p \
-- CountiesTopo.json
Well I plugged output.json back into my d3 code and it gave me a stripped-down map: just the outline of the state of Georgia: no counties!
So hmm … to explore topojson more, why not try converting my original .shp?
-o output.json \
-p \
-- input.shp
Gives me:
Trace: { [Error: ENOENT, open 'input.dbf'] errno: 34, code: 'ENOENT', path: 'input.dbf' }
at output (/usr/local/lib/node_modules/topojson/bin/topojson:232:29)
at notify (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:49:26)
at EventEmitter.<anonymous> (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:39:11)
at EventEmitter.emit (events.js:95:17)
at EventEmitter.ended (/usr/local/lib/node_modules/topojson/node_modules/shapefile/index.js:32:38)
at EventEmitter.emit (events.js:95:17)
at ReadStream.error (/usr/local/lib/node_modules/topojson/node_modules/shapefile/file.js:68:13)
at ReadStream.EventEmitter.emit (events.js:95:17)
at fs.js:1500:12
at Object.oncomplete (fs.js:107:15)
Something wrong with my input, eh? FWIW It's a U.S. Census Tiger shape file.
What do you think? How can I marry my .csv into my .json?
Thanks!

"fatal error: mysql.h: No such file or directory" Compiling mod_auth_mysql-3.0.0

I try to build mod_auth_mysql on my debian Wheezy and I got always this error:
mod_auth_mysql.c:269:19: fatal error: mysql.h: No such file or directory
I have never build package/mod before, I don't understand what I'm doing wrong. I have followed this documentation and used this command line :
apxs2 -c -lmysqlclient -lm -lz mod_auth_mysql.c
Have you tried to compile with -I"/usr/include/mysql", theres mysql.h there probably.

Install MySQL support for Node JS

I'm trying to install MySQL support for NodeJS (v0.6.9) on Ubuntu. I'm issuing the following commands:
sudo apt-get install libmysqlclient-dev
I get no errors. I then install the module for Node:
sudo npm install -g db-mysql
Again. No errors. However, I do get what looks like a warning:
Checking for node path : not found
But the installation ends with:
'build' finished successfully (1.504s)
db-mysql#0.7.6 /usr/local/lib/node_modules/db-mysql
In my program source I now add:
var mysql = require("db-mysql");
But when I run this, I get the following error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'db-mysql'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/home/me/projects/node/test.js:4:13)
at Module._compile (module.js:444:26)
at Object..js (module.js:462:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:482:10)
It obviously can't find the db-mysql module.
Node.js does not looking for modules in global modules folder (/usr/local/lib) by default.
You need to install your module locally by npm install db-mysql.
You can read more about module resolving strategy here: http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders