LCOV - code coverage report
Current view: top level - geospatial - latlong_distance_keymaker.cc (source / functions) Hit Total Coverage
Test: Test Coverage for xapian-core 954b5873a738 Lines: 11 11 100.0 %
Date: 2019-06-30 05:20:33 Functions: 2 2 100.0 %
Branches: 9 16 56.2 %

           Branch data     Line data    Source code
       1                 :            : /** @file latlong_distance_keymaker.cc
       2                 :            :  * @brief LatLongDistanceKeyMaker implementation.
       3                 :            :  */
       4                 :            : /* Copyright 2008 Lemur Consulting Ltd
       5                 :            :  * Copyright 2011 Richard Boulton
       6                 :            :  * Copyright 2012 Olly Betts
       7                 :            :  *
       8                 :            :  * This program is free software; you can redistribute it and/or
       9                 :            :  * modify it under the terms of the GNU General Public License as
      10                 :            :  * published by the Free Software Foundation; either version 2 of the
      11                 :            :  * License, or (at your option) any later version.
      12                 :            :  *
      13                 :            :  * This program is distributed in the hope that it will be useful,
      14                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 :            :  * GNU General Public License for more details.
      17                 :            :  *
      18                 :            :  * You should have received a copy of the GNU General Public License
      19                 :            :  * along with this program; if not, write to the Free Software
      20                 :            :  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
      21                 :            :  * USA
      22                 :            :  */
      23                 :            : 
      24                 :            : #include <config.h>
      25                 :            : 
      26                 :            : #include "xapian/geospatial.h"
      27                 :            : #include "xapian/document.h"
      28                 :            : #include "xapian/queryparser.h" // For sortable_serialise.
      29                 :            : 
      30                 :            : using namespace Xapian;
      31                 :            : using namespace std;
      32                 :            : 
      33                 :            : string
      34                 :          6 : LatLongDistanceKeyMaker::operator()(const Document &doc) const
      35                 :            : {
      36         [ +  - ]:          6 :     string val(doc.get_value(slot));
      37         [ +  + ]:          6 :     if (val.empty()) {
      38         [ +  - ]:          2 :         return defkey;
      39                 :            :     }
      40                 :          8 :     LatLongCoords doccoords;
      41         [ +  - ]:          4 :     doccoords.unserialise(val);
      42         [ +  - ]:          4 :     double distance = (*metric)(centre, doccoords);
      43         [ +  - ]:         10 :     return sortable_serialise(distance);
      44                 :            : }
      45                 :            : 
      46                 :          4 : LatLongDistanceKeyMaker::~LatLongDistanceKeyMaker()
      47                 :            : {
      48         [ +  - ]:          2 :     delete metric;
      49         [ -  + ]:          2 : }

Generated by: LCOV version 1.11