@access.public
    @describeRoute(
        Description('Search for items that are entirely within either a GeoJSON'
                    ' polygon or a circular region.')
        .param('field', 'Name of field containing GeoJSON on which to search.',
               required=True)
        .param('geometry', 'Search query condition as a GeoJSON polygon.',
               required=False)
        .param('center', 'Center of search radius as a GeoJSON point.',
               required=False)
        .param('radius', 'Search radius in meters.', required=False,
               dataType='number')
        .param('limit', 'Result set size limit (default=50).', required=False,
               dataType='integer')
        .param('offset', 'Offset into result set (default=0).', required=False,
               dataType='integer')
        .errorResponse()
        .notes("Either parameter 'geometry' or both parameters 'center' "
               " and 'radius' are required.")
    )
    def within(self, params):
        """
        Search for items that are entirely within either a GeoJSON polygon or a
        circular region. Either parameter 'geometry' or both parameters 'center'
        and 'radius' are required.

        :param params: parameters to the API call, including 'field' and either
                       'geometry' or both 'center' and 'radius'.
        :type params: dict[str, unknown]
        :returns: filtered fields of the matching items with geospatial data
                 appended to the 'geo' field of each item.
        :rtype: list[dict[str, unknown]]
        :raise RestException: on malformed API call.
        """
        self.requireParams(('field',), params)

        if 'geometry' in params:
            try:
                geometry = bson.json_util.loads(params['geometry'])
                GeoJSON.to_instance(geometry, strict=True)

                if geometry['type'] != 'Polygon':
                    raise ValueError
            except (TypeError, ValueError):
                raise RestException("Invalid GeoJSON passed as 'geometry'"
                                    " parameter.")

            condition = {
                '$geometry': geometry
            }

        elif params in 'center' and 'radius' in params:
            try:
                radius = float(params['radius']) / self._RADIUS_OF_EARTH

                if radius < 0.0:
                    raise ValueError
            except ValueError:
                raise RestException("Parameter 'radius' must be a number.")

            try:
                center = bson.json_util.loads(params['center'])
                GeoJSON.to_instance(center, strict=True)

                if center['type'] != 'Point':
                    raise ValueError
            except (TypeError, ValueError):
                raise RestException("Invalid GeoJSON passed as 'center'"
                                    " parameter.")

            condition = {
                '$centerSphere': [center['coordinates'], radius]
            }

        else:
            raise RestException("Either parameter 'geometry' or both parameters"
                                " 'center' and 'radius' are required.")

        if params['field'][:3] == '%s.' % GEOSPATIAL_FIELD:
            field = params['field'].strip()
        else:
            field = '%s.%s' % (GEOSPATIAL_FIELD, params['field'].strip())

        limit, offset, sort = self.getPagingParameters(params, 'lowerName')

        query = {
            field: {
                '$geoWithin': condition
            }
        }

        return self._find(query, limit, offset, sort)
dataset/ETHPy150Open girder/girder/plugins/geospatial/server/geospatial.py/GeospatialItem.within/swapped operands of `in`