@@ -481,6 +481,57 @@ describe('GeoJSON', function() {
481481 } ) ;
482482 } ) ;
483483
484+ it ( 'can accept nested arguments for Point' , function ( done ) {
485+ var data = [
486+ { name : 'Location A' , category : 'Store' , location : { point : { lat : 39.984 , lng : - 75.343 } } }
487+ ] ;
488+
489+ GeoJSON . parse ( data , { Point : [ 'location.point.lat' , 'location.point.lng' ] } , function ( geojson ) {
490+ expect ( geojson . type ) . to . be ( 'FeatureCollection' ) ;
491+ expect ( geojson . features ) . to . be . an ( 'array' ) ;
492+ expect ( geojson . features . length ) . to . be ( 1 ) ;
493+ expect ( geojson . features [ 0 ] . geometry . coordinates [ 0 ] ) . to . equal ( - 75.343 ) ;
494+ expect ( geojson . features [ 0 ] . geometry . coordinates [ 1 ] ) . to . equal ( 39.984 ) ;
495+ done ( ) ;
496+ } ) ;
497+ } ) ;
498+
499+ it ( 'can handle null or undefined values when parsing nested arguments' , function ( done ) {
500+ var data = [
501+ { geo : null } ,
502+ { geo : { line : [ [ 102.0 , 0.0 ] , [ 103.0 , 1.0 ] , [ 104.0 , 0.0 ] , [ 105.0 , 1.0 ] ] } } ,
503+ { geo : { polygon : [ [ 100.0 , 0.0 ] , [ 101.0 , 0.0 ] , [ 101.0 , 1.0 ] , [ 100.0 , 1.0 ] , [ 100.0 , 0.0 ] ] } } ,
504+ { geo : { multipoint : [ [ 100.0 , 0.0 ] , [ 101.0 , 1.0 ] ] } } ,
505+ { geo : { multipolygon : [
506+ [ [ [ 102.0 , 2.0 ] , [ 103.0 , 2.0 ] , [ 103.0 , 3.0 ] , [ 102.0 , 3.0 ] , [ 102.0 , 2.0 ] ] ] ,
507+ [ [ [ 100.0 , 0.0 ] , [ 101.0 , 0.0 ] , [ 101.0 , 1.0 ] , [ 100.0 , 1.0 ] , [ 100.0 , 0.0 ] ] ,
508+ [ [ 100.2 , 0.2 ] , [ 100.8 , 0.2 ] , [ 100.8 , 0.8 ] , [ 100.2 , 0.8 ] , [ 100.2 , 0.2 ] ] ]
509+ ] } } ,
510+ { geo : { multilinestring : [ [ [ 100.0 , 0.0 ] , [ 101.0 , 1.0 ] ] , [ [ 102.0 , 2.0 ] , [ 103.0 , 3.0 ] ] ] } }
511+ ] ;
512+
513+ GeoJSON . parse ( data , {
514+ Point : [ 'geo.nope.point.lng' , 'geo.nope.point.lat' ] ,
515+ LineString : 'geo.nope.line' ,
516+ Polygon : 'geo.nope.polygon' ,
517+ MultiPoint : 'geo.nope.multipoint' ,
518+ MultiPolygon : 'geo.nope.multipolygon' ,
519+ MultiLineString : 'geo.nope.multilinestring'
520+ } , function ( geojson ) {
521+ expect ( geojson . type ) . to . be ( 'FeatureCollection' ) ;
522+ expect ( geojson . features ) . to . be . an ( 'array' ) ;
523+ expect ( geojson . features . length ) . to . be ( 6 ) ;
524+ expect ( geojson . features [ 0 ] . geometry ) . to . be ( false ) ;
525+ expect ( geojson . features [ 1 ] . geometry ) . to . be ( false ) ;
526+ expect ( geojson . features [ 2 ] . geometry ) . to . be ( false ) ;
527+ expect ( geojson . features [ 3 ] . geometry ) . to . be ( false ) ;
528+ expect ( geojson . features [ 4 ] . geometry ) . to . be ( false ) ;
529+ expect ( geojson . features [ 5 ] . geometry ) . to . be ( false ) ;
530+ done ( ) ;
531+ } ) ;
532+
533+ } ) ;
534+
484535 it ( 'can accept up to three arguments for Point in a nested structure' , function ( done ) {
485536 var data = [
486537 { name : 'Location A' , category : 'Store' , location : { lat : 39.984 , lng : - 75.343 , alt : 22026.46 } , street : 'Market' } ,
0 commit comments