const utils = require('./utils')

console.log('hello worker/////////////////')



worker.onMessage((msg) => {
  console.log('[Worker] on appservice message', msg.msg);
  let ALWAYS = []
  msg.msg.markes.forEach((item,index)=>{
	 let distance =  utils.getDistance(msg.msg.coordinate.latitude,msg.msg.coordinate.longitude,item.latitude, item.longitude);
	 if(distance<Number(msg.msg.radius)){
		 ALWAYS.push(index)
	 }
  });
  worker.postMessage({
    msg: ALWAYS,
    buffer: utils.str2ab('hello arrayBuffer from worker')
  })
  console.log(ALWAYS,'距离符合条件的下标')
  // const buffer = msg.buffer
  // console.log('[Worker] on appservice buffer length ', buffer)
  // console.log('[Worker] on appservice buffer', utils.ab2str(buffer))
})