<commit_before><?php

namespace Emfox\GpsBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Emfox\GpsBundle\Entity\Trail;

/**
 * Trail controller.
 *
 * @Route("/trail")
 */
class TrailController extends Controller
{
	/**
	 * Add a new Trail point entities via ajax.
	 *
	 * @Route("/new/{devid}/{lng}/{lat}", name="trail_new")
	 */
	public function newAction($devid,$lng,$lat)
	{
		$em = $this->getDoctrine()->getManager();
		$category = $em->getRepository('EmfoxGpsBundle:Category')->findOneByDevid($devid);
		if(!$category)
		{
			$response = array("code" => 403, "success" => false, "message"=>"Device Unauthorized");
			return new Response(json_encode($response));
		}
		$trail = $em->getRepository('EmfoxGpsBundle:Trail')->findOneBy(
				array('catid'=>$category->getId()),
				array('time'=>'ASC')
		);
		$trail->setTime($category->getUpdatetime());
		$trail->setLat($category->getLat());
		$trail->setLng($category->getLng());
		$em->persist($trail);
		$category->setUpdatetime(new \DateTime());
		$category->setLat($lat);<commit_msg>BaiduMapSDK on Android sometimes return little (but not zero) coordinates, we should ignore those submits.<commit_after><?php

namespace Emfox\GpsBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Emfox\GpsBundle\Entity\Trail;

/**
 * Trail controller.
 *
 * @Route("/trail")
 */
class TrailController extends Controller
{
	/**
	 * Add a new Trail point entities via ajax.
	 *
	 * @Route("/new/{devid}/{lng}/{lat}", name="trail_new")
	 */
	public function newAction($devid,$lng,$lat)
	{
		$em = $this->getDoctrine()->getManager();
		$category = $em->getRepository('EmfoxGpsBundle:Category')->findOneByDevid($devid);
		if(!$category)
		{
			$response = array("code" => 403, "success" => false, "message"=>"Device Unauthorized");
			return new Response(json_encode($response));
		}
		if($lat<0.01 or $lng<0.01){
			$response = array("code" => 403, "success" => false, "message"=>"Invalid Coordinates");
			return new Response(json_encode($response));
		}
		$trail = $em->getRepository('EmfoxGpsBundle:Trail')->findOneBy(
				array('catid'=>$category->getId()),
				array('time'=>'ASC')
		);
		$trail->setTime($category->getUpdatetime());
		$trail->setLat($category->getLat());
		$trail->setLng($category->getLng());
		$em->persist($trail);
		$category->setUpdatetime(new \DateTime());
		$category->setLat($lat);
{'fraction_non_alphanumeric': 0.1782345013477089, 'fraction_numerical': 0.005053908355795148, 'mean_word_length': 5.794050343249428, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5520711', 'n_tokens_mistral': 1021, 'n_tokens_neox': 952, 'n_words': 152}