Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
extend-geojson-properties
Advanced tools
Extende properties/attributes of geojson (array of features or FeatureCollction) from separate dataset of jsons.
Extend properties of geojson (array of features or FeatureCollection) from separate dataset of jsons.
For node.js or with browserify
npm install extend-geojson-properties
To include in html page, download file index.js and rename to extend-geojson-properties.js
<script type="text/javascript" src="path/to/extend-geojson-properties.js"></script>
This create global variable extendGeoJSON.
This module return a function or create global function named extendGeoJSON that extends the geojson properties.
var extendGeoJSON = require('extend-geojson-properties');
extentGeoJSON( geojsons, dataSet, joinMap);
joinMap structure must be like:
var joinMap = {
geoKey: ... ,
dataKey: ... ,
popertyMap: ...
}
{
geoProperty: // string, key path in geojson feature property name
dataProperty: // string, key path in dataSet object property/attributes name
}
Here is the sample data set that I use for test also.
Original geojsons:
var geojsons = [{
type:'Feature',
id: 'id1',
geometry: {type: 'Point', coordinates: [34,50]},
properties: { name: 'name1' }
}, {
type:'Feature',
id: 'id3',
geometry: {type: 'Point', coordinates: [10,35]},
properties: { name: 'name3'}
}, {
type:'Feature',
id: 'id2',
geometry: {type: 'Point', coordinates: [-30,-50]},
properties: { name: 'name2'}
}];
Dataset containing the attributes that we want to extend to geojsons:
var joinDataSet = [{
attr1: 'name1',
attr2: 'val1-2',
attr3: {field : 'val1-3',count:23}
}, {
attr1: 'name2',
attr2: 'val2-2',
attr3: {field : 'val2-3',count:2}
}, {
attr1: 'name3',
attr2: 'val3-2',
attr3: {field : 'val3-3',count:105}
}];
Case 1 joinMap does not contain the propertyMap
var joinMap = {
geoKey:'properties.name', //here geoKey can be feature 'id' also
dataKey: 'attr1'};
extentGeoJSON(geojsons,dataSet,joinMap);
Output of case 1 Now geojsons contains the extended properties like this:
[{
type:'Feature',
id: 'id1',
geometry: {type: 'Point', coordinates: [34,50]},
properties: {
name: 'name1',
attr2: 'val1-2',
attr3: {field : 'val1-3',count:23}
}
}, {
type:'Feature',
id: 'id3',
geometry: {type: 'Point', coordinates: [10,35]},
properties: {
name: 'name3',
attr2: 'val3-2',
attr3: {field : 'val3-3',count:105}
}
}, {
type:'Feature',
id: 'id2',
geometry: {type: 'Point', coordinates: [-30,-50]},
properties: {
name: 'name2',
attr2: 'val2-2',
attr3: {field : 'val2-3',count:2}
}
}]
Case 2 joinMap contains the propertyMap
var joinMap = {
geoKey:'properties.name', //here geoKey can be feature 'id' also
dataKey: 'attr1',
propertyMap:[{
geoProperty: 'prop1',
dataProperty:'attr2'
}, {
geoProperty: 'prop2',
dataProperty: 'attr3.field'
}, {
geoProperty: 'count',
dataProperty: 'attr3.count'
}]
};
extentGeoJSON(geojsons,dataSet,joinMap);
** Output of case 2** Now geojsons contains the extended properties like this:
```jsvascript
[{
type:'Feature',
id: 'id1',
geometry: {type: 'Point', coordinates: [34,50]},
properties: {
name: 'name1',
prop1: 'val1-2',
prop2: 'val1-3',
count: 23
}
}, {
type:'Feature',
id: 'id3',
geometry: {type: 'Point', coordinates: [10,35]},
properties: {
name: 'name3',
prop1: 'val3-2',
prop2: 'val3-3',
count: 105
}
}, {
type:'Feature',
id: 'id2',
geometry: {type: 'Point', coordinates: [-30,-50]},
properties: {
name: 'name2',
prop1: 'val2-2',
prop2: 'val2-3',
count:2
}
}]
##License This project is licensed under the terms of the MIT license.
FAQs
Extende properties/attributes of geojson (array of features or FeatureCollction) from separate dataset of jsons.
The npm package extend-geojson-properties receives a total of 0 weekly downloads. As such, extend-geojson-properties popularity was classified as not popular.
We found that extend-geojson-properties demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.