src/index.js
function multi(name, memberName, membercb, geom, gmlId, params={}){
  var {srsName, gmlIds} = params;
  let multi = `<gml:${name}${attrs({srsName, 'gml:id':gmlId})}>`;
  multi += `<gml:${memberName}>`;
  geom.forEach(function(member, i){
    let _gmlId = member.id || (gmlIds || [])[i] || '';
    if (name == 'MultiGeometry'){
      let memberType = member.type;
      member = member.coordinates;
      multi += membercb[memberType](member, _gmlId, params);
    } else {
      multi += membercb(member, _gmlId, params);
    }
  });
  multi += `</gml:${memberName}>`;
  return multi + `</gml:${name}>`;
}
function multi(name, memberName, membercb, geom, gmlId, params={}){
  var {srsName, gmlIds} = params;
  let multi = `<gml:${name}${attrs({srsName, 'gml:id':gmlId})}>`;
  multi += `<gml:${memberName}>`;
  geom.forEach(function(member, i){
    let _gmlId = member.id || (gmlIds || [])[i] || '';
    if (name == 'MultiGeometry'){
      let memberType = member.type;
      member = member.coordinates;
      multi += membercb[memberType](member, _gmlId, params);
    } else {
      multi += membercb(member, _gmlId, params);
    }
  });
  multi += `</gml:${memberName}>`;
  return multi + `</gml:${name}>`;
}
function multi ( name , memberName , membercb , geom , gmlId , params = { } ) { var { srsName , gmlIds } = params ; let multi = ` ${ name } ${ attrs ( { srsName , 'gml:id' : gmlId } ) } ` ; multi += ` ${ memberName } ` ; geom . forEach ( function ( member , i ) { let _gmlId = member . id || ( gmlIds || [ ] ) [ i ] || '' ; if ( name == 'MultiGeometry' ) { let memberType = member . type ; member = member . coordinates ; multi += membercb [ memberType ] ( member , _gmlId , params ) ; } else { multi += membercb ( member , _gmlId , params ) ; } } ) ; multi += ` ${ memberName } ` ; return multi + ` ${ name } ` ; }
Optional parameters for conversion of geojson to gml geometries
@typedef {Object} Params
@property {?String} params.srsName as string specifying SRS, e.g. 'EPSG:4326'. Only applies to multigeometries.
@property {?Number[]|?String[]} params.gmlIds an array of number/string gml:ids of the member geometries.
@property {?Number|?String} params.srsDimension the dimensionality of each coordinate, i.e. 2 or 3.
 
A handler to compile geometries to multigeometries
@function
@param {String} name the name of the target multigeometry
@param {String} memberName the gml:tag of each multigeometry member.
@param {Object[]|Array} geom an array of geojson geometries
@param {String|Number} gmlId the gml:id of the multigeometry
@param {Params} params optional parameters. Omit gmlIds at your own risk, however.
@returns {String} a string containing gml describing the input multigeometry
@throws {Error} if a member geometry cannot be converted to gml
Optional parameters for conversion of geojson to gml geometries