SQLクエリからpostgis postgresqlデータベースのGISポイントデータへのGeoJSONオブジェクトを構築しようとしています。私の node.js app.js のスニペットを以下に示します。
現状では、タイプと機能の構築は理解していますが、プロパティ配列を各 GeoJSON レコードにアタッチする方法がわかりません (以下では、機能とは別に (照合せずに) 最後にすべてレンダリングします)。
質問: GeoJSON を構築するループ内の各レコードにプロパティがアタッチ (照合) されるようにするには、どうすればよいですか?例?
`function GrabData(bounds, res){
pg.connect(conn, function(err, client){
var moisql = 'SELECT ttl, (ST_AsGeoJSON(the_geom)) as locale from cpag;'
client.query(moisql, function(err, result){
var featureCollection = new FeatureCollection();
for(i=0; i<result.rows.length; i++){
featureCollection.features[i] = JSON.parse(result.rows[i].locale);
featureCollection.properties[i] = JSON.parse(result.rows[i].ttl); //this is wrong
}
res.send(featureCollection);
});
});
}
function FeatureCollection(){
this.type = 'FeatureCollection';
this.features = new Array();
this.properties = new Object; //this is wrong
}
`