-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from geolonia/add-get-data
件数指定して取得、featureの件数を取得できるように修正
- Loading branch information
Showing
2 changed files
with
72 additions
and
1 deletion.
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
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,60 @@ | ||
import { assert } from 'chai'; | ||
import * as fs from 'fs'; | ||
import { GeoJsonlookfor } from '../src/index'; | ||
|
||
|
||
// testデータのディレクトリ名を取得する | ||
const geojson = JSON.parse(fs.readFileSync(`${__dirname}/test.geojson`, 'utf8')); | ||
|
||
/* ******************* | ||
* 取得するデータ別のテスト | ||
* *******************/ | ||
describe('Test by return value', () => { | ||
|
||
// 件数を取得する | ||
it('Get the number of cases', () => { | ||
const gl = new GeoJsonlookfor(geojson); | ||
const res = gl.match('スイーツ').getFeatureCount(); | ||
assert.deepEqual(4, res); | ||
}); | ||
|
||
// 指定した件数分featureを取得する | ||
it('Get the number of cases', () => { | ||
const gl = new GeoJsonlookfor(geojson); | ||
const res = gl.match('スイーツ').getGeoJSON(2); | ||
assert.deepEqual({ | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"name": "スイーツショップ", | ||
"address": "埼玉県桶川市川田谷", | ||
"category": "スイーツ" | ||
}, | ||
"geometry": { | ||
"coordinates": [ | ||
139.517720985072, | ||
35.99865685174926 | ||
], | ||
"type": "Point" | ||
} | ||
},{ | ||
"type": "Feature", | ||
"properties": { | ||
"name": "菓子店", | ||
"address": "埼玉県川越市中老袋", | ||
"category": "スイーツ" | ||
}, | ||
"geometry": { | ||
"coordinates": [ | ||
139.5371783066526, | ||
35.941979468748585 | ||
], | ||
"type": "Point" | ||
} | ||
} | ||
] | ||
}, res); | ||
}); | ||
}); |