Merge branch 'master' of https://github.com/mapnik/mapnik
This commit is contained in:
commit
61dd5dccab
43 changed files with 337 additions and 456 deletions
34
CITATION.cff
Normal file
34
CITATION.cff
Normal file
|
@ -0,0 +1,34 @@
|
|||
# This CITATION.cff file was generated with cffinit.
|
||||
# Visit https://bit.ly/cffinit to generate yours today!
|
||||
|
||||
cff-version: 1.2.0
|
||||
title: mapnik
|
||||
message: >-
|
||||
If you use this software, please cite it using the
|
||||
metadata from this file.
|
||||
type: software
|
||||
authors:
|
||||
- given-names: Artem
|
||||
family-names: Pavlenko
|
||||
identifiers:
|
||||
- type: url
|
||||
value: 'https://github.com/mapnik/mapnik'
|
||||
description: GitHub Repository
|
||||
- type: swh
|
||||
value: >-
|
||||
swh:1:dir:3f5758e17e9d54016ca694268da68cf6856fab58
|
||||
description: Software Archive
|
||||
repository-code: 'https://github.com/mapnik/mapnik'
|
||||
url: 'https://mapnik.org/'
|
||||
abstract: >-
|
||||
Mapnik is an open source toolkit for developing
|
||||
mapping applications. At the core is a C++ shared
|
||||
library providing algorithms and patterns for
|
||||
spatial data access and visualization.
|
||||
keywords:
|
||||
- mapping
|
||||
- gis
|
||||
- cartography
|
||||
- beautiful-maps
|
||||
- rendering
|
||||
license: LGPL-2.1
|
|
@ -159,10 +159,12 @@ if(harfbuzz_FOUND)
|
|||
message(STATUS "Found harfbuzz native cmake")
|
||||
list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz)
|
||||
else()
|
||||
# we use our "own" FindHarfBuzz. See https://github.com/mapnik/mapnik/pull/4191#issuecomment-874728157 for more details
|
||||
message(STATUS "Fallback to FindHarfBuzz")
|
||||
mapnik_find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED COMPONENTS ICU)
|
||||
list(APPEND MAPNIK_OPTIONAL_LIBS HarfBuzz::HarfBuzz HarfBuzz::ICU)
|
||||
# Use pkg-config when harfbuzz is not found.
|
||||
# It might be possible that in future version harfbuzz could only be found via pkg-config.
|
||||
# harfbuzz related discussion: https://github.com/harfbuzz/harfbuzz/issues/2653
|
||||
message(STATUS "harfbuzz not found via cmake. Searching via pkg-config...")
|
||||
pkg_check_modules(harfbuzz REQUIRED IMPORTED_TARGET harfbuzz>=${HARFBUZZ_MIN_VERSION})
|
||||
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::harfbuzz)
|
||||
endif()
|
||||
|
||||
if(USE_EXTERNAL_MAPBOX_GEOMETRY)
|
||||
|
@ -306,7 +308,7 @@ endif()
|
|||
|
||||
if(USE_PROJ)
|
||||
#https://proj.org/development/cmake.html
|
||||
mapnik_find_package(PROJ ${PROJ_MIN_VERSION} QUIET)
|
||||
mapnik_find_package(PROJ QUIET)
|
||||
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
|
||||
if(NOT PROJ_FOUND)
|
||||
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
|
||||
|
@ -317,6 +319,9 @@ if(USE_PROJ)
|
|||
set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}")
|
||||
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::PROJ)
|
||||
else()
|
||||
if(PROJ_VERSION VERSION_LESS PROJ_MIN_VERSION)
|
||||
message(FATAL_ERROR "Proj needs to be at least version ${PROJ_MIN_VERSION}")
|
||||
endif()
|
||||
list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES})
|
||||
list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE $<BUILD_INTERFACE:${PROJ_INCLUDE_DIRS}>)
|
||||
endif()
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
{
|
||||
"name": "use-ninja",
|
||||
"hidden": true,
|
||||
"generator": "Ninja"
|
||||
"generator": "Ninja",
|
||||
"cacheVariables": {
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "default-build-dir",
|
||||
"hidden": true,
|
||||
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||
"cacheVariables": {
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
|
||||
}
|
||||
"binaryDir": "${sourceDir}/build/${presetName}"
|
||||
},
|
||||
{
|
||||
"name": "debug-build",
|
||||
|
@ -29,6 +29,15 @@
|
|||
"USE_LOG_SEVERITY": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "release-with-debug-build",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||
"USE_DEBUG_OUTPUT": "OFF",
|
||||
"USE_LOG": "OFF"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "release-build",
|
||||
"hidden": true,
|
||||
|
@ -191,5 +200,18 @@
|
|||
"name": "linux-gcc-release",
|
||||
"configurePreset": "linux-gcc-release"
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "test-default",
|
||||
"hidden": true,
|
||||
"output": {
|
||||
"outputOnFailure": true
|
||||
},
|
||||
"execution": {
|
||||
"noTestsAction": "error",
|
||||
"stopOnFailure": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,187 +0,0 @@
|
|||
# Copyright (c) 2012, Intel Corporation
|
||||
# Copyright (c) 2019 Sony Interactive Entertainment Inc.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Intel Corporation nor the names of its contributors may
|
||||
# be used to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# Try to find Harfbuzz include and library directories.
|
||||
#
|
||||
# After successful discovery, this will set for inclusion where needed:
|
||||
# HarfBuzz_INCLUDE_DIRS - containg the HarfBuzz headers
|
||||
# HarfBuzz_LIBRARIES - containg the HarfBuzz library
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindHarfBuzz
|
||||
--------------
|
||||
|
||||
Find HarfBuzz headers and libraries.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
``HarfBuzz::HarfBuzz``
|
||||
The HarfBuzz library, if found.
|
||||
|
||||
``HarfBuzz::ICU``
|
||||
The HarfBuzz ICU library, if found.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables in your project:
|
||||
|
||||
``HarfBuzz_FOUND``
|
||||
true if (the requested version of) HarfBuzz is available.
|
||||
``HarfBuzz_VERSION``
|
||||
the version of HarfBuzz.
|
||||
``HarfBuzz_LIBRARIES``
|
||||
the libraries to link against to use HarfBuzz.
|
||||
``HarfBuzz_INCLUDE_DIRS``
|
||||
where to find the HarfBuzz headers.
|
||||
``HarfBuzz_COMPILE_OPTIONS``
|
||||
this should be passed to target_compile_options(), if the
|
||||
target is not used for linking
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_HARFBUZZ QUIET harfbuzz)
|
||||
set(HarfBuzz_COMPILE_OPTIONS ${PC_HARFBUZZ_CFLAGS_OTHER})
|
||||
set(HarfBuzz_VERSION ${PC_HARFBUZZ_CFLAGS_VERSION})
|
||||
|
||||
find_path(HarfBuzz_INCLUDE_DIR
|
||||
NAMES hb.h
|
||||
HINTS ${PC_HARFBUZZ_INCLUDEDIR} ${PC_HARFBUZZ_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES harfbuzz
|
||||
)
|
||||
|
||||
find_library(HarfBuzz_LIBRARY
|
||||
NAMES ${HarfBuzz_NAMES} harfbuzz
|
||||
HINTS ${PC_HARFBUZZ_LIBDIR} ${PC_HARFBUZZ_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if (HarfBuzz_INCLUDE_DIR AND NOT HarfBuzz_VERSION)
|
||||
if (EXISTS "${HarfBuzz_INCLUDE_DIR}/hb-version.h")
|
||||
file(READ "${HarfBuzz_INCLUDE_DIR}/hb-version.h" _harfbuzz_version_content)
|
||||
|
||||
string(REGEX MATCH "#define +HB_VERSION_STRING +\"([0-9]+\.[0-9]+\.[0-9]+)\"" _dummy "${_harfbuzz_version_content}")
|
||||
set(HarfBuzz_VERSION "${CMAKE_MATCH_1}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if ("${HarfBuzz_FIND_VERSION}" VERSION_GREATER "${HarfBuzz_VERSION}")
|
||||
message(FATAL_ERROR "Required version (" ${HarfBuzz_FIND_VERSION} ") is higher than found version (" ${HarfBuzz_VERSION} ")")
|
||||
endif ()
|
||||
|
||||
# Find components
|
||||
if (HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY)
|
||||
set(_HarfBuzz_REQUIRED_LIBS_FOUND ON)
|
||||
set(HarfBuzz_LIBS_FOUND "HarfBuzz (required): ${HarfBuzz_LIBRARY}")
|
||||
else ()
|
||||
set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF)
|
||||
set(HarfBuzz_LIBS_NOT_FOUND "HarfBuzz (required)")
|
||||
endif ()
|
||||
|
||||
if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS)
|
||||
pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu)
|
||||
set(HarfBuzz_ICU_COMPILE_OPTIONS ${PC_HARFBUZZ_ICU_CFLAGS_OTHER})
|
||||
|
||||
find_path(HarfBuzz_ICU_INCLUDE_DIR
|
||||
NAMES hb-icu.h
|
||||
HINTS ${PC_HARFBUZZ_ICU_INCLUDEDIR} ${PC_HARFBUZZ_ICU_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES harfbuzz
|
||||
)
|
||||
|
||||
find_library(HarfBuzz_ICU_LIBRARY
|
||||
NAMES ${HarfBuzz_ICU_NAMES} harfbuzz-icu
|
||||
HINTS ${PC_HARFBUZZ_ICU_LIBDIR} ${PC_HARFBUZZ_ICU_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if (HarfBuzz_ICU_LIBRARY)
|
||||
if (HarfBuzz_FIND_REQUIRED_ICU)
|
||||
list(APPEND HarfBuzz_LIBS_FOUND "ICU (required): ${HarfBuzz_ICU_LIBRARY}")
|
||||
else ()
|
||||
list(APPEND HarfBuzz_LIBS_FOUND "ICU (optional): ${HarfBuzz_ICU_LIBRARY}")
|
||||
endif ()
|
||||
else ()
|
||||
if (HarfBuzz_FIND_REQUIRED_ICU)
|
||||
set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF)
|
||||
list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (required)")
|
||||
else ()
|
||||
list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (optional)")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT HarfBuzz_FIND_QUIETLY)
|
||||
if (HarfBuzz_LIBS_FOUND)
|
||||
message(STATUS "Found the following HarfBuzz libraries:")
|
||||
foreach (found ${HarfBuzz_LIBS_FOUND})
|
||||
message(STATUS " ${found}")
|
||||
endforeach ()
|
||||
endif ()
|
||||
if (HarfBuzz_LIBS_NOT_FOUND)
|
||||
message(STATUS "The following HarfBuzz libraries were not found:")
|
||||
foreach (found ${HarfBuzz_LIBS_NOT_FOUND})
|
||||
message(STATUS " ${found}")
|
||||
endforeach ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(HarfBuzz
|
||||
FOUND_VAR HarfBuzz_FOUND
|
||||
REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY _HarfBuzz_REQUIRED_LIBS_FOUND
|
||||
VERSION_VAR HarfBuzz_VERSION
|
||||
)
|
||||
|
||||
if (HarfBuzz_LIBRARY AND NOT TARGET HarfBuzz::HarfBuzz)
|
||||
add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(HarfBuzz::HarfBuzz PROPERTIES
|
||||
IMPORTED_LOCATION "${HarfBuzz_LIBRARY}"
|
||||
INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (HarfBuzz_ICU_LIBRARY AND NOT TARGET HarfBuzz::ICU)
|
||||
add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(HarfBuzz::ICU PROPERTIES
|
||||
IMPORTED_LOCATION "${HarfBuzz_ICU_LIBRARY}"
|
||||
INTERFACE_COMPILE_OPTIONS "${HarfBuzz_ICU_COMPILE_OPTIONS}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_ICU_INCLUDE_DIR}"
|
||||
)
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(
|
||||
HarfBuzz_INCLUDE_DIR
|
||||
HarfBuzz_ICU_INCLUDE_DIR
|
||||
HarfBuzz_LIBRARY
|
||||
HarfBuzz_ICU_LIBRARY
|
||||
)
|
||||
|
||||
if (HarfBuzz_FOUND)
|
||||
set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY} ${HarfBuzz_ICU_LIBRARY})
|
||||
set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR} ${HarfBuzz_ICU_INCLUDE_DIR})
|
||||
endif ()
|
|
@ -27,7 +27,6 @@ install(
|
|||
FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWebP.cmake"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindHarfBuzz.cmake"
|
||||
DESTINATION ${MAPNIK_CMAKE_DIR}/Modules
|
||||
)
|
||||
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2021 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_MAKE_UNIQUE_HPP
|
||||
#define MAPNIK_MAKE_UNIQUE_HPP
|
||||
|
||||
// http://stackoverflow.com/questions/14131454/visual-studio-2012-cplusplus-and-c-11
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800 || !defined(_MSC_VER) && __cplusplus <= 201103L
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace std {
|
||||
|
||||
// C++14 backfill from http://herbsutter.com/gotw/_102/
|
||||
template<typename T, typename ...Args>
|
||||
inline std::unique_ptr<T> make_unique(Args&& ...args) {
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MAPNIK_MAKE_UNIQUE_HPP
|
|
@ -54,6 +54,14 @@ class MAPNIK_DECL mapped_memory_cache :
|
|||
std::unordered_map<std::string,mapped_region_ptr> cache_;
|
||||
public:
|
||||
bool insert(std::string const& key, mapped_region_ptr);
|
||||
/**
|
||||
* @brief removes the resource identified by key from the cache, if exists
|
||||
*
|
||||
* @param key unique identifier for the resource
|
||||
* @return true if the resource was removed
|
||||
* @return false if the resource was not removed or wasn't in the cache
|
||||
*/
|
||||
bool remove(std::string const& key);
|
||||
boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
|
||||
void clear();
|
||||
};
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
typename ContType::iterator itr=pool_.begin();
|
||||
while ( itr!=pool_.end())
|
||||
{
|
||||
if (!itr->unique())
|
||||
if (itr->use_count() > 1)
|
||||
{
|
||||
++itr;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/geometry/box2d.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
|
||||
// stl
|
||||
#include <memory>
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define MAPNIK_FILE_IO_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/util/utf_conv_win.hpp>
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/wkb.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#include <mapnik/geometry/geometry_type.hpp>
|
||||
|
|
78
include/mapnik/util/mapped_memory_file.hpp
Normal file
78
include/mapnik/util/mapped_memory_file.hpp
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2021 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_MEMORY_MAPPED_FILE_HPP
|
||||
#define MAPNIK_MEMORY_MAPPED_FILE_HPP
|
||||
|
||||
#include <mapnik/config.hpp>
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
#include <boost/interprocess/mapped_region.hpp>
|
||||
#include <boost/interprocess/streams/bufferstream.hpp>
|
||||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#else
|
||||
#include <fstream>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace mapnik { namespace util {
|
||||
|
||||
/**
|
||||
* @brief memory mapped file abstraction. Implementation depends on MAPNIK_MEMORY_MAPPED_FILE.
|
||||
* Might be a simple file wrapper, if MAPNIK_MEMORY_MAPPED_FILE=0
|
||||
*
|
||||
*/
|
||||
class MAPNIK_DECL mapped_memory_file : public noncopyable {
|
||||
public:
|
||||
#ifdef MAPNIK_MEMORY_MAPPED_FILE
|
||||
using file_source_type = boost::interprocess::ibufferstream;
|
||||
#else
|
||||
using file_source_type = std::ifstream;
|
||||
#endif
|
||||
|
||||
public:
|
||||
mapped_memory_file();
|
||||
explicit mapped_memory_file(std::string const& file_name);
|
||||
virtual ~mapped_memory_file();
|
||||
|
||||
file_source_type& file();
|
||||
bool is_open() const;
|
||||
void skip(std::streampos bytes);
|
||||
|
||||
/**
|
||||
* @brief deletes the file identified by file_name. Might also remove the file from any caches.
|
||||
*/
|
||||
static void deleteFile(std::string const& file_name);
|
||||
protected:
|
||||
const std::string file_name_;
|
||||
#ifdef MAPNIK_MEMORY_MAPPED_FILE
|
||||
mapnik::mapped_region_ptr mapped_region_;
|
||||
#endif
|
||||
file_source_type file_;
|
||||
};
|
||||
|
||||
|
||||
} }
|
||||
|
||||
#endif
|
|
@ -42,7 +42,6 @@
|
|||
#include <mapnik/util/geometry_to_ds_type.hpp>
|
||||
#include <mapnik/value/types.hpp>
|
||||
#include <mapnik/util/fs.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/util/spatial_index.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
|
@ -54,6 +53,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
MAPNIK_DISABLE_WARNING_POP
|
||||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#endif
|
||||
#include <mapnik/util/mapped_memory_file.hpp>
|
||||
|
||||
// stl
|
||||
#include <sstream>
|
||||
|
@ -121,35 +121,8 @@ csv_datasource::csv_datasource(parameters const& params)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined (MAPNIK_MEMORY_MAPPED_FILE)
|
||||
using file_source_type = boost::interprocess::ibufferstream;
|
||||
file_source_type in;
|
||||
mapnik::mapped_region_ptr mapped_region;
|
||||
boost::optional<mapnik::mapped_region_ptr> memory =
|
||||
mapnik::mapped_memory_cache::instance().find(filename_, true);
|
||||
if (memory)
|
||||
{
|
||||
mapped_region = *memory;
|
||||
in.buffer(static_cast<char*>(mapped_region->get_address()),mapped_region->get_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("could not create file mapping for " + filename_);
|
||||
}
|
||||
#elif defined (_WIN32)
|
||||
std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary);
|
||||
if (!in.is_open())
|
||||
{
|
||||
throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + "'");
|
||||
}
|
||||
#else
|
||||
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
|
||||
if (!in.is_open())
|
||||
{
|
||||
throw mapnik::datasource_exception("CSV Plugin: could not open: '" + filename_ + "'");
|
||||
}
|
||||
#endif
|
||||
parse_csv(in);
|
||||
mapnik::util::mapped_memory_file in_file{filename_};
|
||||
parse_csv(in_file.file());
|
||||
|
||||
if (has_disk_index_ && !extent_initialized_)
|
||||
{
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include <mapnik/util/geometry_to_ds_type.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/util/file_io.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/geometry/boost_adapters.hpp>
|
||||
|
||||
using mapnik::datasource;
|
||||
|
|
|
@ -48,7 +48,6 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/util/file_io.hpp>
|
||||
#include <mapnik/util/geometry_to_ds_type.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/geometry/boost_adapters.hpp>
|
||||
#include <mapnik/util/fs.hpp>
|
||||
#include <mapnik/util/spatial_index.hpp>
|
||||
|
|
|
@ -51,31 +51,12 @@ dbf_file::dbf_file()
|
|||
record_(0) {}
|
||||
|
||||
dbf_file::dbf_file(std::string const& file_name)
|
||||
:num_records_(0),
|
||||
:mapped_memory_file{file_name},
|
||||
num_records_(0),
|
||||
num_fields_(0),
|
||||
record_length_(0),
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
file_(),
|
||||
#elif defined(_WIN32)
|
||||
file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary),
|
||||
#else
|
||||
file_(file_name.c_str() ,std::ios::in | std::ios::binary),
|
||||
#endif
|
||||
record_(0)
|
||||
{
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::instance().find(file_name,true);
|
||||
if (memory)
|
||||
{
|
||||
mapped_region_ = *memory;
|
||||
file_.buffer(static_cast<char*>((*memory)->get_address()),(*memory)->get_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("could not create file mapping for "+file_name);
|
||||
}
|
||||
#endif
|
||||
if (file_)
|
||||
{
|
||||
read_header();
|
||||
|
@ -88,16 +69,6 @@ dbf_file::~dbf_file()
|
|||
::operator delete(record_);
|
||||
}
|
||||
|
||||
|
||||
bool dbf_file::is_open()
|
||||
{
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
return (file_.buffer().second > 0);
|
||||
#else
|
||||
return file_.is_open();
|
||||
#endif
|
||||
}
|
||||
|
||||
int dbf_file::num_records() const
|
||||
{
|
||||
return num_records_;
|
||||
|
@ -274,8 +245,3 @@ int dbf_file::read_int()
|
|||
mapnik::read_int32_ndr(b,val);
|
||||
return val;
|
||||
}
|
||||
|
||||
void dbf_file::skip(int bytes)
|
||||
{
|
||||
file_.seekg(bytes,std::ios::cur);
|
||||
}
|
||||
|
|
|
@ -28,14 +28,7 @@
|
|||
#include <mapnik/util/noncopyable.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/interprocess/streams/bufferstream.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
#endif
|
||||
#include <mapnik/util/mapped_memory_file.hpp>
|
||||
|
||||
// stl
|
||||
#include <vector>
|
||||
|
@ -54,25 +47,18 @@ struct field_descriptor
|
|||
};
|
||||
|
||||
|
||||
class dbf_file : private mapnik::util::noncopyable
|
||||
class dbf_file : public mapnik::util::mapped_memory_file
|
||||
{
|
||||
private:
|
||||
int num_records_;
|
||||
int num_fields_;
|
||||
std::size_t record_length_;
|
||||
std::vector<field_descriptor> fields_;
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
boost::interprocess::ibufferstream file_;
|
||||
mapnik::mapped_region_ptr mapped_region_;
|
||||
#else
|
||||
std::ifstream file_;
|
||||
#endif
|
||||
char* record_;
|
||||
public:
|
||||
dbf_file();
|
||||
dbf_file(std::string const& file_name);
|
||||
~dbf_file();
|
||||
bool is_open();
|
||||
int num_records() const;
|
||||
int num_fields() const;
|
||||
field_descriptor const& descriptor(int col) const;
|
||||
|
@ -83,7 +69,6 @@ private:
|
|||
void read_header();
|
||||
int read_short();
|
||||
int read_int();
|
||||
void skip(int bytes);
|
||||
};
|
||||
|
||||
#endif //DBFFILE_HPP
|
||||
|
|
|
@ -33,7 +33,6 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/util/fs.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/util/utf_conv_win.hpp>
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/datasource.hpp>
|
||||
#include <mapnik/util/is_clockwise.hpp>
|
||||
#include <mapnik/geometry/correct.hpp>
|
||||
|
|
|
@ -35,16 +35,12 @@
|
|||
#include <mapnik/geometry/box2d.hpp>
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/interprocess/mapped_region.hpp>
|
||||
#include <boost/interprocess/streams/bufferstream.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#endif
|
||||
#include <mapnik/util/noncopyable.hpp>
|
||||
|
||||
#include <mapnik/util/mapped_memory_file.hpp>
|
||||
|
||||
using mapnik::box2d;
|
||||
using mapnik::read_int32_ndr;
|
||||
using mapnik::read_int32_xdr;
|
||||
|
@ -143,64 +139,24 @@ struct shape_record
|
|||
std::size_t length() {return size;}
|
||||
};
|
||||
|
||||
class shape_file : mapnik::util::noncopyable
|
||||
class shape_file : public mapnik::util::mapped_memory_file
|
||||
{
|
||||
public:
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
using file_source_type = boost::interprocess::ibufferstream;
|
||||
using record_type = shape_record<MappedRecordTag>;
|
||||
mapnik::mapped_region_ptr mapped_region_;
|
||||
#else
|
||||
using file_source_type = std::ifstream;
|
||||
using record_type = shape_record<RecordTag>;
|
||||
#endif
|
||||
|
||||
file_source_type file_;
|
||||
|
||||
shape_file() {}
|
||||
|
||||
shape_file(std::string const& file_name) :
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
file_()
|
||||
#elif defined(_WIN32)
|
||||
file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary)
|
||||
#else
|
||||
file_(file_name.c_str(), std::ios::in | std::ios::binary)
|
||||
#endif
|
||||
shape_file(std::string const& file_name)
|
||||
: mapped_memory_file(file_name)
|
||||
{
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
boost::optional<mapnik::mapped_region_ptr> memory =
|
||||
mapnik::mapped_memory_cache::instance().find(file_name,true);
|
||||
|
||||
if (memory)
|
||||
{
|
||||
mapped_region_ = *memory;
|
||||
file_.buffer(static_cast<char*>(mapped_region_->get_address()),mapped_region_->get_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("could not create file mapping for "+file_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
~shape_file() {}
|
||||
|
||||
inline file_source_type& file()
|
||||
{
|
||||
return file_;
|
||||
}
|
||||
|
||||
inline bool is_open() const
|
||||
{
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
return (file_.buffer().second > 0);
|
||||
#else
|
||||
return file_.is_open();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void read_record(record_type& rec)
|
||||
{
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
|
@ -241,11 +197,6 @@ public:
|
|||
file_.read(reinterpret_cast<char*>(&envelope), sizeof(envelope));
|
||||
}
|
||||
|
||||
inline void skip(std::streampos bytes)
|
||||
{
|
||||
file_.seekg(bytes, std::ios::cur);
|
||||
}
|
||||
|
||||
inline void rewind()
|
||||
{
|
||||
seek(100);
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <mapnik/json/topojson_utils.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/util/file_io.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
|
||||
using mapnik::datasource;
|
||||
using mapnik::parameters;
|
||||
|
|
|
@ -223,6 +223,7 @@ target_sources(mapnik PRIVATE
|
|||
target_sources(mapnik PRIVATE
|
||||
util/math.cpp
|
||||
util/utf_conv_win.cpp
|
||||
util/mapped_memory_file.cpp
|
||||
)
|
||||
|
||||
if(USE_CAIRO)
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include <mapnik/image_compositing.hpp>
|
||||
#include <mapnik/image_filter.hpp>
|
||||
#include <mapnik/image_any.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/image_any.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
|
|
|
@ -274,6 +274,7 @@ source = Split(
|
|||
renderer_common/render_thunk_extractor.cpp
|
||||
renderer_common/pattern_alignment.cpp
|
||||
util/math.cpp
|
||||
util/mapped_memory_file.cpp
|
||||
value.cpp
|
||||
"""
|
||||
)
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#if defined(HAVE_CAIRO)
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#if defined(HAVE_CAIRO)
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
#include <mapnik/cairo/cairo_renderer.hpp>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#if defined(HAVE_CAIRO)
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
#include <mapnik/proj_transform.hpp>
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <mapnik/text/face.hpp>
|
||||
#include <mapnik/util/fs.hpp>
|
||||
#include <mapnik/util/file_io.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#if defined(GRID_RENDERER)
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/grid/grid_rasterizer.hpp>
|
||||
#include <mapnik/grid/grid_renderer.hpp>
|
||||
|
|
|
@ -56,6 +56,14 @@ bool mapped_memory_cache::insert(std::string const& uri, mapped_region_ptr mem)
|
|||
return cache_.emplace(uri,mem).second;
|
||||
}
|
||||
|
||||
bool mapped_memory_cache::remove(std::string const& key)
|
||||
{
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
#endif
|
||||
return cache_.erase(key) > 0;
|
||||
}
|
||||
|
||||
boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const& uri, bool update_cache)
|
||||
{
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/renderer_common/render_markers_symbolizer.hpp>
|
||||
#include <mapnik/renderer_common/render_thunk_extractor.hpp>
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/text/harfbuzz_shaper.hpp>
|
||||
#include <mapnik/util/math.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <mapnik/config_error.hpp>
|
||||
#include <mapnik/text/properties_util.hpp>
|
||||
#include <mapnik/boolean.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
|
|
76
src/util/mapped_memory_file.cpp
Normal file
76
src/util/mapped_memory_file.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#include <mapnik/util/mapped_memory_file.hpp>
|
||||
#include <mapnik/util/fs.hpp>
|
||||
#ifdef _WIN32
|
||||
#include <mapnik/util/utf_conv_win.hpp>
|
||||
#endif
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
mapped_memory_file::mapped_memory_file() {}
|
||||
|
||||
mapped_memory_file::mapped_memory_file(std::string const &file_name)
|
||||
: file_name_{file_name},
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
file_()
|
||||
#elif defined(_WIN32)
|
||||
file_(mapnik::utf8_to_utf16(file_name), std::ios::in | std::ios::binary)
|
||||
#else
|
||||
file_(file_name.c_str(), std::ios::in | std::ios::binary)
|
||||
#endif
|
||||
{
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
boost::optional<mapnik::mapped_region_ptr> memory =
|
||||
mapnik::mapped_memory_cache::instance().find(file_name, true);
|
||||
|
||||
if (memory)
|
||||
{
|
||||
mapped_region_ = *memory;
|
||||
file_.buffer(static_cast<char*>(mapped_region_->get_address()),mapped_region_->get_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("could not create file mapping for "+file_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
mapped_memory_file::file_source_type& mapped_memory_file::file()
|
||||
{
|
||||
return file_;
|
||||
}
|
||||
|
||||
bool mapped_memory_file::is_open() const
|
||||
{
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
return (file_.buffer().second > 0);
|
||||
#else
|
||||
return file_.is_open();
|
||||
#endif
|
||||
}
|
||||
|
||||
void mapped_memory_file::skip(std::streampos bytes)
|
||||
{
|
||||
file_.seekg(bytes, std::ios::cur);
|
||||
}
|
||||
|
||||
void mapped_memory_file::deleteFile(std::string const &file_name)
|
||||
{
|
||||
#ifdef MAPNIK_MEMORY_MAPPED_FILE
|
||||
mapped_memory_cache::instance().remove(file_name);
|
||||
#endif
|
||||
if(util::exists(file_name)) {
|
||||
util::remove(file_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mapped_memory_file::~mapped_memory_file()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@
|
|||
#include <mapnik/util/math.hpp>
|
||||
#include <mapnik/vertex_cache.hpp>
|
||||
#include <mapnik/offset_converter.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/image_reader.hpp>
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
*****************************************************************************/
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/wkb.hpp>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
//mapnik
|
||||
#include <mapnik/debug.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/xml_tree.hpp>
|
||||
#include <mapnik/xml_attribute_cast.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
|
|
@ -33,6 +33,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
#include <mapnik/util/mapped_memory_file.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -107,10 +108,7 @@ TEST_CASE("invalid shapeindex")
|
|||
std::string path = "test/data/shp/boundaries.shp";
|
||||
std::string index_path = path.substr(0, path.rfind(".")) + ".index";
|
||||
// remove *.index if present
|
||||
if (mapnik::util::exists(index_path))
|
||||
{
|
||||
mapnik::util::remove(index_path);
|
||||
}
|
||||
mapnik::util::mapped_memory_file::deleteFile(index_path);
|
||||
// count features
|
||||
|
||||
std::size_t feature_count = count_shapefile_features(path);
|
||||
|
@ -132,10 +130,7 @@ TEST_CASE("invalid shapeindex")
|
|||
CHECK(feature_count_indexed == 0);
|
||||
}
|
||||
// remove *.index if present
|
||||
if (mapnik::util::exists(index_path))
|
||||
{
|
||||
mapnik::util::remove(index_path);
|
||||
}
|
||||
mapnik::util::mapped_memory_file::deleteFile(index_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -159,10 +154,7 @@ TEST_CASE("shapeindex")
|
|||
|
||||
std::string index_path = path.substr(0, path.rfind(".")) + ".index";
|
||||
// remove *.index if present
|
||||
if (mapnik::util::exists(index_path))
|
||||
{
|
||||
mapnik::util::remove(index_path);
|
||||
}
|
||||
mapnik::util::mapped_memory_file::deleteFile(index_path);
|
||||
// count features
|
||||
std::size_t feature_count = count_shapefile_features(path);
|
||||
// create *.index
|
||||
|
@ -180,10 +172,7 @@ TEST_CASE("shapeindex")
|
|||
// ensure number of features are the same
|
||||
REQUIRE(feature_count == feature_count_indexed);
|
||||
// remove *.index if present
|
||||
if (mapnik::util::exists(index_path))
|
||||
{
|
||||
mapnik::util::remove(index_path);
|
||||
}
|
||||
mapnik::util::mapped_memory_file::deleteFile(index_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ MAPNIK_DISABLE_WARNING_PUSH
|
|||
#include <boost/filesystem/convenience.hpp>
|
||||
#include <boost/optional/optional_io.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
#include <mapnik/util/mapped_memory_file.hpp>
|
||||
|
||||
inline void make_directory(std::string const& dir) {
|
||||
boost::filesystem::create_directories(dir);
|
||||
|
@ -205,10 +206,7 @@ SECTION("image_util : save_to_file/save_to_stream/save_to_string")
|
|||
CHECK(0 == std::memcmp(im2.bytes(), im.bytes(), im.width() * im.height()));
|
||||
}
|
||||
}
|
||||
if (mapnik::util::exists(filename))
|
||||
{
|
||||
mapnik::util::remove(filename);
|
||||
}
|
||||
mapnik::util::mapped_memory_file::deleteFile(filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,15 +28,9 @@
|
|||
#include <mapnik/util/utf_conv_win.hpp>
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
#include <mapnik/warning.hpp>
|
||||
MAPNIK_DISABLE_WARNING_PUSH
|
||||
#include <mapnik/warning_ignore.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/interprocess/mapped_region.hpp>
|
||||
#include <boost/interprocess/streams/bufferstream.hpp>
|
||||
MAPNIK_DISABLE_WARNING_POP
|
||||
#include <mapnik/mapped_memory_cache.hpp>
|
||||
#endif
|
||||
#include <mapnik/util/mapped_memory_file.hpp>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
@ -53,37 +47,11 @@ std::pair<bool,typename T::value_type::first_type> process_csv_file(T & boxes, s
|
|||
p.separator_ = separator;
|
||||
p.quote_ = quote;
|
||||
|
||||
#if defined(MAPNIK_MEMORY_MAPPED_FILE)
|
||||
using file_source_type = boost::interprocess::ibufferstream;
|
||||
file_source_type csv_file;
|
||||
mapnik::mapped_region_ptr mapped_region;
|
||||
boost::optional<mapnik::mapped_region_ptr> memory =
|
||||
mapnik::mapped_memory_cache::instance().find(filename, true);
|
||||
if (memory)
|
||||
{
|
||||
mapped_region = *memory;
|
||||
csv_file.buffer(static_cast<char*>(mapped_region->get_address()),mapped_region->get_size());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::clog << "Error : cannot mmap " << filename << std::endl;
|
||||
return std::make_pair(false, box_type(p.extent_));
|
||||
}
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
std::ifstream csv_file(mapnik::utf8_to_utf16(filename),std::ios_base::in | std::ios_base::binary);
|
||||
#else
|
||||
std::ifstream csv_file(filename.c_str(),std::ios_base::in | std::ios_base::binary);
|
||||
#endif
|
||||
if (!csv_file.is_open())
|
||||
{
|
||||
std::clog << "Error : cannot open " << filename << std::endl;
|
||||
return std::make_pair(false, box_type(p.extent_));
|
||||
}
|
||||
#endif
|
||||
|
||||
util::mapped_memory_file csv_file{filename};
|
||||
try
|
||||
{
|
||||
p.parse_csv_and_boxes(csv_file, boxes);
|
||||
p.parse_csv_and_boxes(csv_file.file(), boxes);
|
||||
return std::make_pair(true, box_type(p.extent_));
|
||||
}
|
||||
catch (std::exception const& ex)
|
||||
|
|
69
vcpkg.json
Normal file
69
vcpkg.json
Normal file
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"name": "mapnik",
|
||||
"version-string": "master",
|
||||
"description": "Mapnik is an open source toolkit for developing mapping applications.",
|
||||
"homepage": "https://github.com/mapnik/mapnik",
|
||||
"dependencies": [
|
||||
"boost-assign",
|
||||
"boost-bimap",
|
||||
"boost-filesystem",
|
||||
"boost-geometry",
|
||||
"boost-gil",
|
||||
"boost-interprocess",
|
||||
{
|
||||
"name": "boost-locale",
|
||||
"features": [
|
||||
"icu"
|
||||
]
|
||||
},
|
||||
"boost-msm",
|
||||
"boost-program-options",
|
||||
"boost-property-tree",
|
||||
{
|
||||
"name": "boost-regex",
|
||||
"features": [
|
||||
"icu"
|
||||
]
|
||||
},
|
||||
"boost-spirit",
|
||||
"boost-system",
|
||||
"cairo",
|
||||
"cairomm",
|
||||
{
|
||||
"name": "freetype",
|
||||
"features": [
|
||||
"bzip2",
|
||||
"png"
|
||||
]
|
||||
},
|
||||
"gdal",
|
||||
{
|
||||
"name": "harfbuzz",
|
||||
"features": [
|
||||
"icu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "harfbuzz",
|
||||
"features": [
|
||||
"coretext"
|
||||
],
|
||||
"platform": "osx"
|
||||
},
|
||||
"icu",
|
||||
"libjpeg-turbo",
|
||||
"libodb-pgsql",
|
||||
"libpng",
|
||||
"libpq",
|
||||
"libwebp",
|
||||
"libxml2",
|
||||
"mapbox-geometry",
|
||||
"mapbox-polylabel",
|
||||
"mapbox-variant",
|
||||
"proj4",
|
||||
"protozero",
|
||||
"sqlite3",
|
||||
"tiff",
|
||||
"zlib"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue