├── geoserver ├── README └── plugin │ ├── README │ ├── src │ └── main │ │ └── java │ │ ├── com │ │ └── xoomcode │ │ │ └── acidmaps │ │ │ ├── simplify │ │ │ └── SimplifyMethod.java │ │ │ ├── renderer │ │ │ └── RendererType.java │ │ │ ├── interpolate │ │ │ └── InterpolationStrategy.java │ │ │ ├── core │ │ │ ├── Color.java │ │ │ ├── AcidMapParameters.java │ │ │ ├── Point.java │ │ │ ├── Bounds.java │ │ │ └── Configuration.java │ │ │ ├── error │ │ │ ├── AcidMapException.java │ │ │ ├── Validator.java │ │ │ └── ErrorImageFactory.java │ │ │ ├── cache │ │ │ ├── Dataset.java │ │ │ ├── DatasetCacheKey.java │ │ │ └── DatasetCache.java │ │ │ ├── constants │ │ │ └── ErrorConstants.java │ │ │ └── adapter │ │ │ └── JCAdapter.java │ │ └── applicationContext.xml │ ├── javadoc.xml │ ├── build.xml │ └── pom.xml ├── ams ├── build │ └── README ├── jni │ ├── build │ │ └── README │ ├── CMakeLists.txt │ ├── README │ ├── JCAdapter.h │ └── JCAdapter.cc ├── test │ ├── build │ │ └── README │ ├── README │ ├── CMakeLists.txt │ ├── acid_maps_test.cc │ ├── test_runner.cc │ ├── render │ │ ├── gradient_renderer_intervals_test.cc │ │ └── sparse_renderer_intervals_test.cc │ ├── simplify │ │ ├── grid_simplifier_test.cc │ │ ├── copy_simplifier_test.cc │ │ ├── sampling_simplifier_test.cc │ │ └── extremes_simplifier_test.cc │ ├── transform │ │ └── transformer_test.cc │ └── interpolations_test.cc ├── src │ ├── CMakeLists.txt │ ├── core │ │ ├── size.cc │ │ ├── size.h │ │ ├── pixel.h │ │ ├── point.h │ │ ├── bounds.cc │ │ ├── validator.h │ │ ├── color.h │ │ ├── rectangle.h │ │ ├── bounds.h │ │ ├── rectangle.cc │ │ ├── validator.cc │ │ └── configuration.h │ ├── constants │ │ └── constants.h │ ├── encode │ │ ├── encoding_format.h │ │ ├── encoder_factory.cc │ │ ├── png │ │ │ ├── png_encoder.cc │ │ │ └── png_encoder.h │ │ ├── encoder_factory.h │ │ └── encoder.h │ ├── simplify │ │ ├── copy_simplifier.cc │ │ ├── simplify_method.h │ │ ├── sampling_simplifier.h │ │ ├── copy_simplifier.h │ │ ├── sampling_simplifier.cc │ │ ├── simplifier_factory.h │ │ ├── simplifier_factory.cc │ │ ├── extremes_simplifier.h │ │ ├── grid_simplifier.h │ │ ├── simplifier.h │ │ ├── extremes_simplifier.cc │ │ └── grid_simplifier.cc │ ├── render │ │ ├── renderer_type.h │ │ ├── renderer_factory.cc │ │ ├── dense_renderer.h │ │ ├── renderer_factory.h │ │ ├── sparse_renderer.h │ │ ├── gradient_renderer.h │ │ ├── renderer.h │ │ ├── dense_renderer.cc │ │ ├── sparse_renderer.cc │ │ └── gradient_renderer.cc │ ├── interpolate │ │ ├── inverse_distance_weighting.h │ │ ├── dummy_interpolation.h │ │ ├── linear_interpolation.h │ │ ├── interpolation_strategy.h │ │ ├── nearest_neighbor.h │ │ ├── interpolation_factory.h │ │ ├── interpolation_factory.cc │ │ ├── interpolation.h │ │ ├── nearest_neighbor.cc │ │ ├── inverse_distance_weighting.cc │ │ ├── dummy_interpolation.cc │ │ └── linear_interpolation.cc │ ├── transform │ │ ├── transformer.cc │ │ └── transformer.h │ ├── acid_maps.h │ └── acid_maps.cc └── README ├── flex ├── lib │ ├── lib │ │ ├── gtween2.swc │ │ └── openscales-fx.swc │ ├── bin │ │ └── acidmaps_as.swc │ ├── .settings │ │ ├── com.adobe.flexbuilder.project.prefs │ │ └── org.eclipse.core.resources.prefs │ ├── src │ │ └── com │ │ │ └── xoomcode │ │ │ ├── constants │ │ │ └── Constants.as │ │ │ └── acidmaps │ │ │ ├── renderer │ │ │ └── RendererType.as │ │ │ ├── simplify │ │ │ └── SimplifyMethod.as │ │ │ ├── interpolate │ │ │ └── InterpolationStrategy.as │ │ │ └── AMSParameters.as │ ├── .project │ ├── .flexLibProperties │ └── .actionScriptProperties └── demo │ └── AcidMapFlexClient │ ├── lib │ ├── acidmaps_as.swc │ └── openscales-fx.swc │ ├── .settings │ ├── com.adobe.flexbuilder.project.prefs │ └── org.eclipse.core.resources.prefs │ ├── bin-debug │ ├── AcidMapFlexClient.swf │ ├── playerProductInstall.swf │ ├── history │ │ ├── history.css │ │ └── historyFrame.html │ ├── index.html │ ├── AcidMapFlexClient.html │ └── AC_OETags.js │ ├── html-template │ ├── playerProductInstall.swf │ ├── history │ │ ├── history.css │ │ └── historyFrame.html │ ├── index.template.html │ └── AC_OETags.js │ ├── .flexProperties │ ├── .project │ ├── .actionScriptProperties │ └── src │ ├── RangeItem.mxml │ ├── RangeComponent.mxml │ └── AcidMapFlexClient.mxml ├── .gitignore ├── examples └── isolines │ ├── README.md │ ├── archsites.sld │ └── isolines.html ├── README └── LICENSE /geoserver/README: -------------------------------------------------------------------------------- 1 | Geoserver files 2 | -------------------------------------------------------------------------------- /geoserver/plugin/README: -------------------------------------------------------------------------------- 1 | Geoserver plugin files 2 | -------------------------------------------------------------------------------- /ams/build/README: -------------------------------------------------------------------------------- 1 | This path is intended to do out-of-source builds of libacid-maps 2 | -------------------------------------------------------------------------------- /ams/jni/build/README: -------------------------------------------------------------------------------- 1 | This path is intended to do out-of-source builds of libacid-maps-jni 2 | 3 | -------------------------------------------------------------------------------- /ams/test/build/README: -------------------------------------------------------------------------------- 1 | This path is intended to do out-of-source builds of libacid-maps tests 2 | 3 | -------------------------------------------------------------------------------- /flex/lib/lib/gtween2.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/lib/lib/gtween2.swc -------------------------------------------------------------------------------- /flex/lib/bin/acidmaps_as.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/lib/bin/acidmaps_as.swc -------------------------------------------------------------------------------- /flex/lib/lib/openscales-fx.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/lib/lib/openscales-fx.swc -------------------------------------------------------------------------------- /flex/lib/.settings/com.adobe.flexbuilder.project.prefs: -------------------------------------------------------------------------------- 1 | #Thu Feb 17 18:14:47 ART 2011 2 | eclipse.preferences.version=1 3 | upgradeSDK/fb4= 4 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/lib/acidmaps_as.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/demo/AcidMapFlexClient/lib/acidmaps_as.swc -------------------------------------------------------------------------------- /flex/lib/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Fri Nov 12 16:51:42 ART 2010 2 | eclipse.preferences.version=1 3 | encoding/=utf-8 4 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/lib/openscales-fx.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/demo/AcidMapFlexClient/lib/openscales-fx.swc -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/.settings/com.adobe.flexbuilder.project.prefs: -------------------------------------------------------------------------------- 1 | #Fri Feb 18 12:02:16 ART 2011 2 | eclipse.preferences.version=1 3 | upgradeSDK/fb4= 4 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Tue Nov 09 10:47:28 ART 2010 2 | eclipse.preferences.version=1 3 | encoding/=utf-8 4 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/bin-debug/AcidMapFlexClient.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/demo/AcidMapFlexClient/bin-debug/AcidMapFlexClient.swf -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/bin-debug/playerProductInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/demo/AcidMapFlexClient/bin-debug/playerProductInstall.swf -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/html-template/playerProductInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XoomCode/AcidMaps/HEAD/flex/demo/AcidMapFlexClient/html-template/playerProductInstall.swf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | geoserver/plugin/.classpath 2 | geoserver/plugin/.project 3 | geoserver/plugin/.settings 4 | geoserver/plugin/target 5 | geoserver/jni/build 6 | lib/build/ 7 | lib/test/build 8 | lib/bin/ 9 | **/*.class 10 | -------------------------------------------------------------------------------- /ams/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED (VERSION 2.8) 2 | PROJECT (ACID_MAPS_LIB) 3 | 4 | FILE(GLOB_RECURSE sources *.cc) 5 | ADD_LIBRARY (acid-maps SHARED ${sources}) 6 | 7 | SET(CMAKE_BUILD_TYPE Release) 8 | 9 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/.flexProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /ams/README: -------------------------------------------------------------------------------- 1 | DON'T EVER DO THIS. 2 | cd ams # DON'T 3 | cmake . # DO 4 | make # THIS 5 | 6 | INSTEAD 7 | cd ams/build # YOU SHOULD 8 | cmake ../src # DO 9 | make # THIS 10 | 11 | Or you will fill your source dir with intermediate files generated with cmake. 12 | -------------------------------------------------------------------------------- /ams/test/README: -------------------------------------------------------------------------------- 1 | DON'T EVER DO THIS. 2 | cd lib/test # DON'T 3 | cmake . # DO 4 | make # THIS 5 | 6 | INSTEAD 7 | cd lib/test/build # YOU SHOULD 8 | cmake ../ # DO 9 | make # THIS 10 | 11 | Or you will fill your source dir with intermediate files generated with cmake. 12 | -------------------------------------------------------------------------------- /ams/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | project (ACID_MAPS_LIB_TEST) 3 | 4 | FILE(GLOB_RECURSE test_sources *_test.cc) 5 | ADD_EXECUTABLE(test_runner test_runner.cc ${test_sources}) 6 | TARGET_LINK_LIBRARIES(test_runner cppunit acid-maps) 7 | 8 | SET(CMAKE_BUILD_TYPE Release) 9 | 10 | -------------------------------------------------------------------------------- /ams/jni/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED (VERSION 2.8) 2 | PROJECT (ACID_MAPS_JNI) 3 | 4 | FIND_PACKAGE(JNI REQUIRED) 5 | INCLUDE_DIRECTORIES(${JNI_INCLUDE_DIRS}) 6 | 7 | FILE(GLOB_RECURSE sources ../src/*.cc) 8 | ADD_LIBRARY (acid-maps-jni SHARED JCAdapter.cc ${sources}) 9 | 10 | SET(CMAKE_BUILD_TYPE Release) 11 | 12 | -------------------------------------------------------------------------------- /ams/jni/README: -------------------------------------------------------------------------------- 1 | DON'T EVER DO THIS. 2 | cd geoserver/jni # DON'T 3 | cmake . # DO 4 | make # THIS 5 | 6 | INSTEAD 7 | cd geoserver/jni/build # YOU SHOULD 8 | cmake ../ # DO 9 | make # THIS 10 | 11 | Or you will fill your source dir with intermediate files generated with cmake. 12 | -------------------------------------------------------------------------------- /examples/isolines/README.md: -------------------------------------------------------------------------------- 1 | This example uses the archsites layer which is included in Geoserver by default. 2 | 3 | Values from 'cat' field are used to build the isolines. 4 | 5 | Apply the SLD style (_archsites.sld_) to the layer to see the values of each point. 6 | 7 | To get more defined lines, you must change the RENDERER_TYPE parameter to sparse method: 8 | 9 | `RENDERER_TYPE: 1` -------------------------------------------------------------------------------- /flex/lib/src/com/xoomcode/constants/Constants.as: -------------------------------------------------------------------------------- 1 | package com.xoomcode.constants 2 | { 3 | public class Constants 4 | { 5 | /** 6 | * Number of values per point in the dataset 7 | * Currently is 3: X, Y, Value 8 | */ 9 | public static const VPP:int = 3; 10 | 11 | /** 12 | * Number of bytes in an RGBA pixel 13 | */ 14 | public static const RGBA:int = 4; 15 | 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /ams/test/acid_maps_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class AcidMapsTest : public CppUnit::TestFixture { 4 | CPPUNIT_TEST_SUITE(AcidMapsTest); 5 | CPPUNIT_TEST( defaultConfiguration ); 6 | CPPUNIT_TEST_SUITE_END(); 7 | 8 | public: 9 | void defaultConfiguration () { 10 | CPPUNIT_ASSERT(true); 11 | } 12 | }; 13 | 14 | CPPUNIT_TEST_SUITE_REGISTRATION( AcidMapsTest ); 15 | -------------------------------------------------------------------------------- /flex/lib/src/com/xoomcode/acidmaps/renderer/RendererType.as: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.renderer 2 | { 3 | public class RendererType 4 | { 5 | public static const DENSE:int = 0; // Intervals are indexed 6 | public static const SPARSE:int = 1; // Finds the right interval with a b-tree 7 | public static const GRADIENT:int = 2; // // Smooth color rendering 8 | 9 | } 10 | } -------------------------------------------------------------------------------- /flex/lib/src/com/xoomcode/acidmaps/simplify/SimplifyMethod.as: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.simplify 2 | { 3 | public class SimplifyMethod 4 | { 5 | public static const COPY:int = 0; // Copy the first 6 | public static const GRID:int = 1; // Uniform distributed grid 7 | public static const RANDOM:int = 2; // Random samples 8 | public static const EXTREMES:int = 3; // Highest and lowest values 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/bin-debug/history/history.css: -------------------------------------------------------------------------------- 1 | /* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */ 2 | 3 | #ie_historyFrame { width: 0px; height: 0px; display:none } 4 | #firefox_anchorDiv { width: 0px; height: 0px; display:none } 5 | #safari_formDiv { width: 0px; height: 0px; display:none } 6 | #safari_rememberDiv { width: 0px; height: 0px; display:none } 7 | -------------------------------------------------------------------------------- /ams/src/core/size.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file size.cc 3 | * @brief Size implementation 4 | * 5 | * @date 2010-11-05 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "./size.h" 10 | 11 | namespace acid_maps { 12 | 13 | Size::Size() { 14 | width = 0; 15 | height = 0; 16 | } 17 | 18 | Size::Size(int width, int height) { 19 | this->width = width; 20 | this->height = height; 21 | } 22 | 23 | }; // namespace acid_maps 24 | 25 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/html-template/history/history.css: -------------------------------------------------------------------------------- 1 | /* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */ 2 | 3 | #ie_historyFrame { width: 0px; height: 0px; display:none } 4 | #firefox_anchorDiv { width: 0px; height: 0px; display:none } 5 | #safari_formDiv { width: 0px; height: 0px; display:none } 6 | #safari_rememberDiv { width: 0px; height: 0px; display:none } 7 | -------------------------------------------------------------------------------- /ams/src/constants/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_CONSTANTS_CONSTANTS_H_ 2 | #define LIB_CONSTANTS_CONSTANTS_H_ 3 | /** 4 | * @file acid_maps.cc 5 | * @brief 6 | * 7 | * @date 2010-11-02 8 | * @authors Fabio R. Panettieri 9 | * 10 | * @todo Brief and description 11 | */ 12 | namespace acid_maps { 13 | 14 | /** 15 | * Number of bytes in an RGBA pixel 16 | */ 17 | static const int RGBA = 4; 18 | 19 | }; // namespace acid_maps 20 | 21 | #endif // LIB_CONSTANTS_CONSTANTS_H_ 22 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/simplify/SimplifyMethod.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.xoomcode.acidmaps.simplify; 5 | 6 | /** 7 | * @date 09/11/2010 8 | * @author cfarina 9 | * 10 | * List of available Simplify methods 11 | * 12 | */ 13 | public class SimplifyMethod { 14 | public static final int COPY = 0; 15 | public static final int GRID = 1; 16 | public static final int RANDOM = 2; 17 | public static final int EXTREMES = 3; 18 | } 19 | -------------------------------------------------------------------------------- /ams/src/encode/encoding_format.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_ENCODE_ENCODING_FORMAT_H_ 2 | #define LIB_SOURCE_ENCODE_ENCODING_FORMAT_H_ 3 | /** 4 | * @file encoding_format.h 5 | * 6 | * @date 2010-11-10 7 | * @authors Fabio R. Panettieri 8 | */ 9 | 10 | namespace acid_maps { 11 | 12 | /** 13 | * @brief List of available simplification methods 14 | */ 15 | enum EncodingFormat { 16 | PNG = 0 17 | }; 18 | 19 | }; // namespace acid_maps 20 | 21 | #endif // LIB_SOURCE_ENCODE_ENCODING_FORMAT_H_ 22 | 23 | -------------------------------------------------------------------------------- /ams/src/core/size.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CORE_SIZE_H_ 2 | #define LIB_SOURCE_CORE_SIZE_H_ 3 | /** 4 | * @file size.h 5 | * @brief Size structure definition 6 | * 7 | * @date 2010-11-05 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief Size representation 15 | */ 16 | struct Size { 17 | Size(); 18 | Size(int width, int height); 19 | 20 | int width; 21 | int height; 22 | }; 23 | 24 | }; // namespace acid_maps 25 | 26 | #endif // LIB_SOURCE_CORE_SIZE_H_ 27 | 28 | -------------------------------------------------------------------------------- /ams/src/core/pixel.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CORE_PIXEL_H_ 2 | #define LIB_SOURCE_CORE_PIXEL_H_ 3 | /** 4 | * @file pixel.h 5 | * @brief 6 | * 7 | * @date 2011-01-13 8 | * @authors Fabio R. Panettieri 9 | * 10 | * @todo Brief and description 11 | * 12 | */ 13 | 14 | namespace acid_maps { 15 | 16 | /** 17 | * @brief 18 | * 19 | * @todo Brief and description 20 | */ 21 | struct Pixel { 22 | int x; 23 | int y; 24 | float value; 25 | }; 26 | 27 | }; // namespace acid_maps 28 | 29 | #endif //LIB_SOURCE_CORE_PIXEL_H_ 30 | 31 | -------------------------------------------------------------------------------- /ams/src/encode/encoder_factory.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file encoder_factory.cc 3 | * @brief Encoder factory implementation 4 | * 5 | * @date 2010-11-10 6 | * @authors Fabio R. Panettieri 7 | */ 8 | #include "./encoder.h" 9 | #include "./encoding_format.h" 10 | #include "./encoder_factory.h" 11 | #include "png/png_encoder.h" 12 | 13 | namespace acid_maps { 14 | 15 | Encoder* EncoderFactory::get(int format) { 16 | switch (format) { 17 | case PNG: 18 | return new PngEncoder(); 19 | } 20 | } 21 | 22 | }; // namespace acid_maps 23 | 24 | -------------------------------------------------------------------------------- /ams/jni/JCAdapter.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class JCAdapter */ 4 | 5 | #ifndef _Included_JCAdapter 6 | #define _Included_JCAdapter 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: JCAdapter 12 | * Method: interpolateC 13 | * Signature: (LConfiguration;[B)V 14 | */ 15 | JNIEXPORT jobject JNICALL Java_com_xoomcode_acidmaps_adapter_JCAdapter_interpolateC(JNIEnv *, jobject, jobject); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /ams/src/core/point.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CORE_POINT_H_ 2 | #define LIB_SOURCE_CORE_POINT_H_ 3 | /** 4 | * @file point.h 5 | * @brief 6 | * 7 | * @date 2011-01-13 8 | * @authors Fabio R. Panettieri 9 | * 10 | * @todo Brief and description 11 | * 12 | */ 13 | 14 | namespace acid_maps { 15 | 16 | /** 17 | * @brief 18 | * 19 | * @todo Brief and description 20 | */ 21 | struct Point { 22 | float x; 23 | float y; 24 | float value; 25 | }; 26 | 27 | }; // namespace acid_maps 28 | 29 | #endif //LIB_SOURCE_CORE_POINT_H_ 30 | 31 | -------------------------------------------------------------------------------- /ams/test/test_runner.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * A simple program that executes each registered test 3 | * 4 | * @date 2010-11-04 5 | * @authors Fabio R. Panettieri 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | int main (int argc, char* argv[]) { 12 | CppUnit::TextUi::TestRunner runner; 13 | CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); 14 | runner.addTest( registry.makeTest() ); 15 | return !runner.run( "", false ); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /flex/lib/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | acidmaps_as 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.flexlibnature 16 | com.adobe.flexbuilder.project.actionscriptnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /flex/lib/src/com/xoomcode/acidmaps/interpolate/InterpolationStrategy.as: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.interpolate 2 | { 3 | public class InterpolationStrategy 4 | { 5 | public static const DUMMY:int = 0; // No interpolation uses the assigned value 6 | public static const NEAREST_NEIGHBOR:int = 1; // N Neighbors found 7 | public static const LINEAR:int = 2; // Value decays with distance 8 | public static const INVERSE_DISTANCE_WEIGHTING:int = 3; // Simple implementation of IDW 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/renderer/RendererType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.xoomcode.acidmaps.renderer; 5 | 6 | /** 7 | * @date 09/11/2010 8 | * @author cfarina 9 | * 10 | * List of available rendere types 11 | */ 12 | public class RendererType { 13 | 14 | public static final int DENSE = 0; // Intervals are indexed 15 | public static final int SPARSE = 1; // Finds the right interval with a b-tree 16 | public static final int GRADIENT = 2; // Smooth color rendering 17 | } 18 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AcidMapFlexClient 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.flexnature 16 | com.adobe.flexbuilder.project.actionscriptnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /ams/src/core/bounds.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file bounds.cc 3 | * @brief Bounds implementation 4 | * 5 | * @date 2010-11-03 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "./bounds.h" 10 | 11 | namespace acid_maps { 12 | 13 | Bounds::Bounds() { 14 | min_x = 0.0; 15 | min_y = 0.0; 16 | max_x = 0.0; 17 | max_y = 0.0; 18 | } 19 | 20 | Bounds::Bounds(float min_x, float min_y, float max_x, float max_y) { 21 | this->min_x = min_x; 22 | this->min_y = min_y; 23 | this->max_x = max_x; 24 | this->max_y = max_y; 25 | } 26 | 27 | }; // namespace acid_maps 28 | 29 | -------------------------------------------------------------------------------- /ams/src/core/validator.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CORE_VALIDATOR_H_ 2 | #define LIB_SOURCE_CORE_VALIDATOR_H_ 3 | /** 4 | * @file validator.h 5 | * @brief Validates the configuration 6 | * 7 | * @date 2011-03-04 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * Configuration forward declaration 15 | */ 16 | struct Configuration; 17 | 18 | class Validator { 19 | 20 | public: 21 | int validate(Configuration* configuration); 22 | 23 | }; 24 | 25 | }; // namespace acid_maps 26 | 27 | #endif // LIB_SOURCE_CORE_VALIDATOR_H_ 28 | 29 | -------------------------------------------------------------------------------- /ams/src/core/color.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CORE_COLOR_H_ 2 | #define LIB_SOURCE_CORE_COLOR_H_ 3 | /** 4 | * @file color.h 5 | * @brief 6 | * 7 | * @date 2011-03-14 8 | * @authors Fabio R. Panettieri 9 | * 10 | * @todo Brief and description 11 | * 12 | */ 13 | 14 | namespace acid_maps { 15 | 16 | /** 17 | * @brief 18 | * 19 | * @todo Brief and description 20 | */ 21 | struct Color { 22 | unsigned char r; 23 | unsigned char g; 24 | unsigned char b; 25 | unsigned char a; 26 | }; 27 | 28 | }; // namespace acid_maps 29 | 30 | #endif //LIB_SOURCE_CORE_COLOR_H_ 31 | 32 | -------------------------------------------------------------------------------- /flex/lib/.flexLibProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ams/src/simplify/copy_simplifier.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file copy_simplifier.cc 3 | * @brief Copy simplifier implementation 4 | * 5 | * @date 2010-11-03 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "../constants/constants.h" 10 | #include "../core/point.h" 11 | #include "./copy_simplifier.h" 12 | #include 13 | 14 | namespace acid_maps { 15 | 16 | void CopySimplifier::simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size) { 17 | std::memcpy(simplified_dataset, dataset, sizeof(Point) * simplify_size); 18 | } 19 | 20 | }; // namespace acid_maps 21 | 22 | -------------------------------------------------------------------------------- /ams/src/render/renderer_type.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_RENDERER_RENDERER_TYPE_H_ 2 | #define LIB_SOURCE_RENDERER_RENDERER_TYPE_H_ 3 | /** 4 | * @file renderer_type.h 5 | * 6 | * @date 2010-11-08 7 | * @authors Fabio R. Panettieri 8 | * @todo 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief List of available 15 | */ 16 | enum RendererType { 17 | DENSE = 0, /// Intervals are indexed 18 | SPARSE = 1, /// Finds the right interval with a b-tree 19 | GRADIENT = 2 /// Smooth color rendering 20 | }; 21 | 22 | }; // namespace acid_maps 23 | 24 | #endif // LIB_SOURCE_RENDERER_RENDERER_TYPE_H_ 25 | 26 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/interpolate/InterpolationStrategy.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.interpolate; 2 | 3 | /** 4 | * @date 10/11/2010 5 | * @author cfarina 6 | * 7 | * It defines the interpolate methods 8 | */ 9 | public class InterpolationStrategy { 10 | 11 | public static final int DUMMY = 0; // No interpolation uses the assigned value 12 | public static final int NEAREST_NEIGHBOR = 1; // N Neighbors found 13 | public static final int LINEAR = 2; // Value decays with distance 14 | public static final int INVERSE_DISTANCE_WEIGHTING = 3; // Simple implementation of IDW 15 | } 16 | -------------------------------------------------------------------------------- /ams/src/simplify/simplify_method.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_SIMPLIFY_SIMPLIFY_METHOD_H_ 2 | #define LIB_SOURCE_SIMPLIFY_SIMPLIFY_METHOD_H_ 3 | /** 4 | * @file simplify_method.h 5 | * 6 | * @date 2010-11-03 7 | * @authors Fabio R. Panettieri 8 | */ 9 | 10 | namespace acid_maps { 11 | 12 | /** 13 | * @brief List of available simplification methods 14 | */ 15 | enum SimplifyMethod { 16 | COPY = 0, /// Copy the first values 17 | GRID = 1, /// Uniform distributed grid 18 | SAMPLING = 2, /// Random samples 19 | EXTREMES = 3 /// Highest and lowest values 20 | }; 21 | 22 | }; // namespace acid_maps 23 | 24 | #endif // LIB_SOURCE_SIMPLIFY_SIMPLIFY_METHOD_H_ 25 | 26 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/core/Color.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author cfarina 3 | * @date 15/03/2011 4 | * 5 | * The Color class is used encapsulate colors in the default sRGB color space 6 | */ 7 | 8 | package com.xoomcode.acidmaps.core; 9 | 10 | public class Color { 11 | 12 | public byte r; 13 | public byte g; 14 | public byte b; 15 | public byte a; 16 | 17 | /** 18 | * Instantiates a new color. 19 | * 20 | * @param r the r 21 | * @param g the g 22 | * @param b the b 23 | * @param a the a 24 | */ 25 | public Color(byte r, byte g, byte b, byte a) { 26 | super(); 27 | this.r = r; 28 | this.g = g; 29 | this.b = b; 30 | this.a = a; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ams/src/encode/png/png_encoder.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file png_encoder.cc 3 | * @brief Png Encoder implementation 4 | * 5 | * @date 2010-11-10 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "../../constants/constants.h" 10 | #include "../../core/size.h" 11 | #include "./png_encoder.h" 12 | #include "lodepng.h" 13 | 14 | #include 15 | 16 | namespace acid_maps { 17 | 18 | void PngEncoder::encode(Size* tile_size, unsigned char* rgba_buffer, unsigned char** output_buffer, unsigned int* output_size) { 19 | size_t size; 20 | LodePNG_encode32(output_buffer, &size, rgba_buffer, tile_size->width, tile_size->height); 21 | *output_size = size; 22 | } 23 | 24 | }; // namespace acid_maps 25 | 26 | -------------------------------------------------------------------------------- /geoserver/plugin/javadoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ams/src/encode/png/png_encoder.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_ENCODE_PNG_ENCODER_H_ 2 | #define LIB_SOURCE_ENCODE_PNG_ENCODER_H_ 3 | /** 4 | * @file png_encoder.h 5 | * @brief Png encoder implementation 6 | * 7 | * Generates a png with the given image 8 | * 9 | * @date 2010-11-10 10 | * @authors Fabio R. Panettieri 11 | */ 12 | 13 | #include "../encoder.h" 14 | 15 | namespace acid_maps { 16 | 17 | /** 18 | * @brief Keeps the dataset untouched 19 | */ 20 | class PngEncoder : public Encoder { 21 | /** 22 | */ 23 | void encode(Size* tile_size, unsigned char* rgba_buffer, unsigned char** output_buffer, unsigned int* output_size); 24 | }; 25 | 26 | }; // namespace acid_maps 27 | 28 | #endif // LIB_SOURCE_ENCODE_PNG_ENCODER_H_ 29 | 30 | -------------------------------------------------------------------------------- /ams/src/core/rectangle.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CORE_RECTANGLE_H_ 2 | #define LIB_SOURCE_CORE_RECTANGLE_H_ 3 | /** 4 | * @file rectangle.h 5 | * @brief Rectangle structure definition 6 | * 7 | * @date 2010-11-09 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief Size representation 15 | */ 16 | class Rectangle { 17 | public: 18 | Rectangle(); 19 | Rectangle(int min_x, int min_y, int max_x, int max_y); 20 | void resize(int min_x, int min_y, int max_x, int max_y); 21 | void intersect(int min_x, int min_y, int max_x, int max_y); 22 | 23 | int min_x; 24 | int min_y; 25 | int max_x; 26 | int max_y; 27 | }; 28 | 29 | }; // namespace acid_maps 30 | 31 | #endif // LIB_SOURCE_CORE_RECTANGLE_H_ 32 | 33 | -------------------------------------------------------------------------------- /ams/src/render/renderer_factory.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file renderer_factory.cc 3 | * @brief Renderer factory implementation 4 | * 5 | * @date 2010-11-08 6 | * @authors Fabio R. Panettieri 7 | */ 8 | #include "./renderer.h" 9 | #include "./renderer_factory.h" 10 | #include "./renderer_type.h" 11 | #include "./dense_renderer.h" 12 | #include "./sparse_renderer.h" 13 | #include "./gradient_renderer.h" 14 | 15 | namespace acid_maps { 16 | 17 | Renderer* RendererFactory::get(int type) { 18 | switch (type) { 19 | case DENSE: 20 | return new DenseRenderer(); 21 | 22 | case SPARSE: 23 | return new SparseRenderer(); 24 | 25 | case GRADIENT: 26 | return new GradientRenderer(); 27 | } 28 | } 29 | 30 | }; // namespace acid_maps 31 | 32 | -------------------------------------------------------------------------------- /ams/src/simplify/sampling_simplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_SIMPLIFY_SAMPLING_SIMPLIFIER_H_ 2 | #define LIB_SOURCE_SIMPLIFY_SAMPLING_SIMPLIFIER_H_ 3 | /** 4 | * @file random_simplifier.h 5 | * @brief Random simplifier implementation 6 | * 7 | * Generates a uniformly distributed random dataset 8 | * 9 | * @date 2011-02-15 10 | * @authors Fabio R. Panettieri 11 | */ 12 | 13 | #include "./simplifier.h" 14 | 15 | namespace acid_maps { 16 | 17 | /** 18 | * @brief 19 | */ 20 | class SamplingSimplifier : public Simplifier { 21 | /** 22 | * @brief 23 | */ 24 | void simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size); 25 | }; 26 | 27 | }; // namespace acid_maps 28 | 29 | #endif // LIB_SOURCE_SIMPLIFY_SAMPLING_SIMPLIFIER_H_ 30 | 31 | -------------------------------------------------------------------------------- /ams/src/encode/encoder_factory.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_ENCODE_ENCODER_FACTORY_H_ 2 | #define LIB_SOURCE_ENCODE_ENCODER_FACTORY_H_ 3 | /** 4 | * @file encoder_factory.h 5 | * @brief Encoder factory definition 6 | * 7 | * @date 2010-11-10 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief Class responsible of creating new encoders 15 | * Based on the Factory Method Pattern 16 | */ 17 | class EncoderFactory { 18 | public: 19 | /** 20 | * @brief Creates the expected encoder 21 | * 22 | * @param format int Encoder output format 23 | * @returns Encoder* 24 | */ 25 | static Encoder* get(int format); 26 | }; 27 | 28 | }; // namespace acid_maps 29 | 30 | #endif // LIB_SOURCE_ENCODE_ENCODER_FACTORY_H_ 31 | 32 | -------------------------------------------------------------------------------- /ams/src/interpolate/inverse_distance_weighting.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_INTERPOLATE_IDW_H_ 2 | #define LIB_SOURCE_INTERPOLATE_IDW_H_ 3 | /** 4 | * @file inverse_distance_weighting.h 5 | * @brief Inverse Distance Weighted Interpolation 6 | * 7 | * @date 2011-01-05 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "./interpolation.h" 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * @todo brief and description 17 | */ 18 | class InverseDistanceWeighting : public Interpolation { 19 | /** 20 | * @todo brief and description 21 | */ 22 | void interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 23 | int radius, float interpolated_bitmap[]); 24 | }; 25 | 26 | }; // namespace acid_maps 27 | 28 | #endif // LIB_SOURCE_INTERPOLATE_LINEAR_INTERPOLATION_H_ 29 | 30 | -------------------------------------------------------------------------------- /ams/src/simplify/copy_simplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_SIMPLIFY_COPY_SIMPLIFIER_H_ 2 | #define LIB_SOURCE_SIMPLIFY_COPY_SIMPLIFIER_H_ 3 | /** 4 | * @file copy_simplifier.h 5 | * @brief Copy simplifier implementation 6 | * 7 | * Keeps the dataset untouched 8 | * 9 | * @date 2010-11-03 10 | * @authors Fabio R. Panettieri 11 | */ 12 | 13 | #include "./simplifier.h" 14 | 15 | namespace acid_maps { 16 | 17 | /** 18 | * @brief Keeps the dataset untouched 19 | */ 20 | class CopySimplifier : public Simplifier { 21 | /** 22 | * @brief It does nothing with the dataset 23 | */ 24 | void simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size); 25 | }; 26 | 27 | }; // namespace acid_maps 28 | 29 | #endif // LIB_SOURCE_SIMPLIFY_COPY_SIMPLIFIER_H_ 30 | 31 | -------------------------------------------------------------------------------- /ams/src/interpolate/dummy_interpolation.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_INTERPOLATE_DUMMY_INTERPOLATION_H_ 2 | #define LIB_SOURCE_INTERPOLATE_DUMMY_INTERPOLATION_H_ 3 | /** 4 | * @file dummy_interpolation.h 5 | * @brief Dummy simplifier implementation 6 | * 7 | * @date 2010-11-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "./interpolation.h" 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * @brief Does nothing 17 | */ 18 | class DummyInterpolation : public Interpolation { 19 | /** 20 | * @brief It allocates an empty bitmap 21 | */ 22 | void interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 23 | int radius, float interpolated_bitmap[]); 24 | }; 25 | 26 | }; // namespace acid_maps 27 | 28 | #endif // LIB_SOURCE_INTERPOLATE_DUMMY_INTERPOLATION_H_ 29 | 30 | -------------------------------------------------------------------------------- /ams/src/simplify/sampling_simplifier.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sampling_simplifier.cc 3 | * @brief Sampling simplifier implementation 4 | * 5 | * @date 2011-02-15 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "../constants/constants.h" 10 | #include "../core/point.h" 11 | #include "./sampling_simplifier.h" 12 | #include 13 | #include 14 | 15 | namespace acid_maps { 16 | 17 | void SamplingSimplifier::simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size) { 18 | if (simplify_size == 0) return; 19 | 20 | int step = dataset_size / simplify_size; 21 | for(int i = 0; i < simplify_size; i++){ 22 | std::memcpy(simplified_dataset + i, dataset + i * step, sizeof(Point)); 23 | } 24 | } 25 | 26 | }; // namespace acid_maps 27 | 28 | -------------------------------------------------------------------------------- /ams/src/render/dense_renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_RENDER_DENSE_RENDERER_H_ 2 | #define LIB_SOURCE_RENDER_DENSE_RENDERER_H_ 3 | /** 4 | * @file dense_renderer.h 5 | * @brief Dense renderer definition 6 | * 7 | * @date 2011-03-14 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "./renderer.h" 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * @brief Renderer optimized for direct access 17 | */ 18 | class DenseRenderer : public Renderer { 19 | void render(float interpolated_bitmap[], Size* tile_size, float intervals[], 20 | int intervals_size, Color* intervals_colors, unsigned char* output_buffer); 21 | 22 | int interval(float value, float intervals[], int intervals_size); 23 | }; 24 | 25 | }; // namespace acid_maps 26 | 27 | #endif // LIB_SOURCE_RENDER_DENSE_RENDERER_H_ 28 | -------------------------------------------------------------------------------- /ams/src/render/renderer_factory.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_RENDERER_RENDERER_FACTORY_H_ 2 | #define LIB_SOURCE_RENDERER_RENDERER_FACTORY_H_ 3 | /** 4 | * @file renderer_factory.h 5 | * @brief Renderer factory definition 6 | * 7 | * @date 2010-11-08 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief Class responsible of creating new renderers 15 | * Based on the Factory Method Pattern 16 | */ 17 | class RendererFactory { 18 | public: 19 | /** 20 | * @brief Creates the expected renderer 21 | * 22 | * @param method int Expected renderer 23 | * @returns Renderer* 24 | */ 25 | static Renderer* get(int type); 26 | }; 27 | 28 | }; // namespace acid_maps 29 | 30 | #endif // LIB_SOURCE_RENDERER_RENDERER_FACTORY_H_ 31 | 32 | -------------------------------------------------------------------------------- /ams/src/interpolate/linear_interpolation.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_INTERPOLATE_LINEAR_INTERPOLATION_H_ 2 | #define LIB_SOURCE_INTERPOLATE_LINEAR_INTERPOLATION_H_ 3 | /** 4 | * @file linear_interpolation.h 5 | * @brief Linear interpolation implementation 6 | * 7 | * @date 2010-11-09 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "./interpolation.h" 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * @todo brief and description 17 | */ 18 | class LinearInterpolation : public Interpolation { 19 | /** 20 | * @todo brief and description 21 | */ 22 | void interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 23 | int radius, float interpolated_bitmap[]); 24 | }; 25 | 26 | }; // namespace acid_maps 27 | 28 | #endif // LIB_SOURCE_INTERPOLATE_LINEAR_INTERPOLATION_H_ 29 | 30 | -------------------------------------------------------------------------------- /ams/src/render/sparse_renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_RENDER_SPARSE_RENDERER_H_ 2 | #define LIB_SOURCE_RENDER_SPARSE_RENDERER_H_ 3 | /** 4 | * @file sparse_renderer.h 5 | * @brief Sparse renderer definition 6 | * 7 | * @date 2010-11-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "./renderer.h" 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * @brief Used to render sparse intervals 17 | */ 18 | class SparseRenderer : public Renderer { 19 | void render(float interpolated_bitmap[], Size* tile_size, float intervals[], 20 | int intervals_size, Color* intervals_colors, unsigned char* output_buffer); 21 | 22 | int interval(float value, float intervals[], int intervals_size); 23 | }; 24 | 25 | }; // namespace acid_maps 26 | 27 | #endif // LIB_SOURCE_RENDER_SPARSE_RENDERER_H_ 28 | -------------------------------------------------------------------------------- /ams/src/encode/encoder.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_ENCODE_ENCODER_H_ 2 | #define LIB_SOURCE_ENCODE_ENCODER_H_ 3 | /** 4 | * @file encode.h 5 | * @brief Encoder definition 6 | * 7 | * @date 2010-11-10 8 | * @authors Fabio R. Panettieri 9 | */ 10 | namespace acid_maps { 11 | 12 | /** 13 | * Forward declaration 14 | */ 15 | struct Size; 16 | 17 | /** 18 | * @brief Renders the raw image 19 | */ 20 | class Encoder { 21 | public: 22 | /** 23 | * @brief Virtual destructor allows proper destructor calls 24 | */ 25 | virtual ~Encoder() {} 26 | /** 27 | * @todo brief 28 | */ 29 | virtual void encode(Size* tile_size, unsigned char* rgba_buffer, unsigned char** output_buffer, unsigned int* output_size) = 0; 30 | }; 31 | 32 | }; // namespace acid_maps 33 | 34 | #endif // LIB_SOURCE_ENCODE_ENCODER_H_ 35 | -------------------------------------------------------------------------------- /ams/src/interpolate/interpolation_strategy.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_INTERPOLATE_INTERPOLATION_STRATEGY_H_ 2 | #define LIB_SOURCE_INTERPOLATE_INTERPOLATION_STRATEGY_H_ 3 | /** 4 | * @file interpolation_strategy.h 5 | * 6 | * @date 2010-11-03 7 | * @authors Fabio R. Panettieri 8 | */ 9 | 10 | namespace acid_maps { 11 | 12 | /** 13 | * @brief List of available simplification methods 14 | */ 15 | enum InterpolationStrategy { 16 | DUMMY = 0, /// No interpolation uses the assigned value 17 | NEAREST_NEIGHBOR = 1, /// N Neighbors found 18 | LINEAR = 2, /// Value decays with distance 19 | INVERSE_DISTANCE_WEIGHTING = 3 /// Simple implementation of IDW 20 | }; 21 | 22 | }; // namespace acid_maps 23 | 24 | #endif // LIB_SOURCE_INTERPOLATE_INTERPOLATION_STRATEGY_H_ 25 | 26 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/core/AcidMapParameters.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.xoomcode.acidmaps.core; 5 | 6 | /** 7 | * @date 09/11/2010 8 | * @author cfarina 9 | * 10 | */ 11 | public class AcidMapParameters { 12 | 13 | public static final String VALUE_COLUMN = "VALUE_COLUMN"; 14 | 15 | public static final String SIMPLIFY_METHOD = "SIMPLIFY_METHOD"; 16 | 17 | public static final String SIMPLIFY_SIZE = "SIMPLIFY_SIZE"; 18 | 19 | public static final String INTERVALS = "INTERVALS[]"; 20 | 21 | public static final String INTERVALS_COLORS = "INTERVALS_COLORS[]"; 22 | 23 | public static final String RENDERER_TYPE = "RENDERER_TYPE"; 24 | 25 | public static final String INTERPOLATION_STRATEGY = "INTERPOLATION_STRATEGY"; 26 | 27 | public static final String RADIUS = "RADIUS"; 28 | } 29 | -------------------------------------------------------------------------------- /ams/src/interpolate/nearest_neighbor.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_INTERPOLATE_NEAREST_NEIGHBOR_H_ 2 | #define LIB_SOURCE_INTERPOLATE_NEAREST_NEIGHBOR_H_ 3 | /** 4 | * @file nearest_neighbor.h 5 | * @brief Nearest neighbor interpolation definition 6 | * 7 | * @date 2010-11-09 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "./interpolation.h" 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * @todo brief 17 | */ 18 | class NearestNeighbor : public Interpolation { 19 | /** 20 | * @todo brief 21 | * @param interpolation_parameter int Represents the of points to consider in a KNN 22 | */ 23 | void interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 24 | int radius, float interpolated_bitmap[]); 25 | }; 26 | 27 | }; // namespace acid_maps 28 | 29 | #endif // LIB_SOURCE_INTERPOLATE_NEAREST_NEIGHBOR_H_ 30 | 31 | -------------------------------------------------------------------------------- /ams/src/simplify/simplifier_factory.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_SIMPLIFY_SIMPLIFIER_FACTORY_H_ 2 | #define LIB_SOURCE_SIMPLIFY_SIMPLIFIER_FACTORY_H_ 3 | /** 4 | * @file simplifier_factory.h 5 | * @brief Simplifier factory declaration 6 | * 7 | * @date 2010-11-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief Class responsible of creating new simplifiers 15 | * Based on the Factory Method Pattern 16 | */ 17 | class SimplifierFactory { 18 | public: 19 | /** 20 | * @brief Creates the requested Simplifier 21 | * 22 | * @param method SimplifyMethod Desired simplify method 23 | * @returns Simplifier* 24 | */ 25 | static Simplifier* get(int method); 26 | }; 27 | 28 | }; // namespace acid_maps 29 | 30 | #endif // LIB_SOURCE_SIMPLIFY_SIMPLIFIER_FACTORY_H_ 31 | 32 | -------------------------------------------------------------------------------- /ams/src/core/bounds.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CORE_BOUNDS_H_ 2 | #define LIB_SOURCE_CORE_BOUNDS_H_ 3 | /** 4 | * @file bounds.h 5 | * @brief Bounds structure definition 6 | * 7 | * @date 2010-11-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief Bounding Box representation 15 | * Instances of this class represent bounding boxes. 16 | * Data stored as min_x, min_y, max_x, max_y floats. 17 | * All values are initialized to 0, however, you should make sure you set them 18 | * before using the bounds for anything. 19 | */ 20 | struct Bounds { 21 | Bounds(); 22 | Bounds(float min_x, float min_y, float max_x, float max_y); 23 | 24 | float min_x; 25 | float min_y; 26 | float max_x; 27 | float max_y; 28 | }; 29 | 30 | }; // namespace acid_maps 31 | 32 | #endif // LIB_SOURCE_CORE_BOUNDS_H_ 33 | 34 | -------------------------------------------------------------------------------- /ams/src/interpolate/interpolation_factory.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_INTERPOLATE_INTERPOLATION_FACTORY_H_ 2 | #define LIB_SOURCE_INTERPOLATE_INTERPOLATION_FACTORY_H_ 3 | /** 4 | * @file interpolation_factory.h 5 | * @brief Interpolation factory declaration 6 | * 7 | * @date 2010-11-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * @brief Class responsible of creating new interpolations 15 | * Based on the Factory Method Pattern 16 | */ 17 | class InterpolationFactory { 18 | public: 19 | /** 20 | * @brief Creates the requested Interpolation 21 | * 22 | * @param method int Expected interpolation 23 | * @returns Interpolation* 24 | */ 25 | static Interpolation* get(int strategy); 26 | }; 27 | 28 | }; // namespace acid_maps 29 | 30 | #endif // LIB_SOURCE_INTERPOLATE_INTERPOLATION_FACTORY_H_ 31 | 32 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/core/Point.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.xoomcode.acidmaps.core; 5 | 6 | // TODO: Auto-generated Javadoc 7 | /** 8 | * A point representing a location in (x, y) coordinate space, 9 | * and a value for that point. 10 | * 11 | * @date 22/02/2011 12 | * @author cfarina 13 | */ 14 | public class Point { 15 | 16 | /** The x. */ 17 | public float x; 18 | 19 | /** The y. */ 20 | public float y; 21 | 22 | /** The value. */ 23 | public float value; 24 | 25 | /** 26 | * Instantiates a new point. 27 | */ 28 | public Point() { 29 | } 30 | 31 | /** 32 | * Instantiates a new point. 33 | * 34 | * @param x the x 35 | * @param y the y 36 | * @param value the value 37 | */ 38 | public Point(float x, float y, float value) { 39 | this.x = x; 40 | this.y = y; 41 | this.value = value; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /ams/src/render/gradient_renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_RENDER_GRADIENT_RENDERER_H_ 2 | #define LIB_SOURCE_RENDER_GRADIENT_RENDERER_H_ 3 | /** 4 | * @file gradient_renderer.h 5 | * @brief Gradient renderer definition 6 | * 7 | * @date 2011-03-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "./renderer.h" 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * @brief Used to render sparse intervals 17 | */ 18 | class GradientRenderer : public Renderer { 19 | void render(float interpolated_bitmap[], Size* tile_size, float intervals[], 20 | int intervals_size, Color* intervals_colors, unsigned char* output_buffer); 21 | 22 | int interval(float value, float intervals[], int intervals_size); 23 | 24 | static const int GRADIENT_INTERVAL_SIZE = 255; 25 | }; 26 | 27 | }; // namespace acid_maps 28 | 29 | #endif // LIB_SOURCE_RENDER_GRADIENT_RENDERER_H_ 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /ams/src/simplify/simplifier_factory.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file simplifier_factory.cc 3 | * @brief Simplifier factory implementation 4 | * 5 | * @date 2010-11-03 6 | * @authors Fabio R. Panettieri 7 | */ 8 | #include "./simplifier.h" 9 | #include "./simplify_method.h" 10 | #include "./simplifier_factory.h" 11 | #include "./copy_simplifier.h" 12 | #include "./grid_simplifier.h" 13 | #include "./sampling_simplifier.h" 14 | #include "./extremes_simplifier.h" 15 | 16 | namespace acid_maps { 17 | 18 | Simplifier* SimplifierFactory::get(int method) { 19 | switch (method) { 20 | case COPY: 21 | return new CopySimplifier(); 22 | 23 | case GRID: 24 | return new GridSimplifier(); 25 | 26 | case SAMPLING: 27 | return new SamplingSimplifier(); 28 | 29 | case EXTREMES: 30 | return new ExtremesSimplifier(); 31 | } 32 | } 33 | 34 | }; // namespace acid_maps 35 | 36 | -------------------------------------------------------------------------------- /ams/src/interpolate/interpolation_factory.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file interpolation_factory.cc 3 | * @brief Interpolation factory implementation 4 | * 5 | * @date 2010-11-03 6 | * @authors Fabio R. Panettieri 7 | */ 8 | #include "./interpolation.h" 9 | #include "./interpolation_factory.h" 10 | #include "./interpolation_strategy.h" 11 | #include "./dummy_interpolation.h" 12 | #include "./nearest_neighbor.h" 13 | #include "./linear_interpolation.h" 14 | #include "./inverse_distance_weighting.h" 15 | 16 | namespace acid_maps { 17 | 18 | Interpolation* InterpolationFactory::get(int strategy) { 19 | switch (strategy) { 20 | case NEAREST_NEIGHBOR: 21 | return new NearestNeighbor(); 22 | 23 | case LINEAR: 24 | return new LinearInterpolation(); 25 | 26 | case INVERSE_DISTANCE_WEIGHTING: 27 | return new InverseDistanceWeighting(); 28 | 29 | default: 30 | return new DummyInterpolation(); 31 | } 32 | } 33 | 34 | }; // namespace acid_maps 35 | 36 | -------------------------------------------------------------------------------- /ams/src/simplify/extremes_simplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_SIMPLIFY_EXTREMES_SIMPLIFIER_H_ 2 | #define LIB_SOURCE_SIMPLIFY_EXTREMES_SIMPLIFIER_H_ 3 | /** 4 | * @file extremes_simplifier.h 5 | * @brief Extremes simplifier implementation 6 | * 7 | * Find the maximum and minimum values 8 | * 9 | * @date 2011-01-27 10 | * @authors Fabio R. Panettieri 11 | */ 12 | 13 | #include "./simplifier.h" 14 | 15 | namespace acid_maps { 16 | 17 | /** 18 | * @brief Keeps the dataset untouched 19 | */ 20 | class ExtremesSimplifier : public Simplifier { 21 | /** 22 | * @brief Returns a set with global extremes 23 | */ 24 | void simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size); 25 | 26 | private: 27 | /** 28 | * @brief Returns if the index already exists in that array 29 | */ 30 | bool in(int index, int* array, int array_size); 31 | 32 | }; 33 | 34 | }; // namespace acid_maps 35 | 36 | #endif // LIB_SOURCE_SIMPLIFY_EXTREMES_SIMPLIFIER_H_ 37 | 38 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/bin-debug/history/historyFrame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 27 | Hidden frame for Browser History support. 28 | 29 | 30 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/html-template/history/historyFrame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 27 | Hidden frame for Browser History support. 28 | 29 | 30 | -------------------------------------------------------------------------------- /flex/lib/.actionScriptProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /ams/src/core/rectangle.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rectangle.cc 3 | * @brief Rectangle implementation 4 | * 5 | * @date 2010-11-09 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "./rectangle.h" 10 | 11 | namespace acid_maps { 12 | 13 | Rectangle::Rectangle() { 14 | min_x = 0; 15 | min_y = 0; 16 | max_x = 0; 17 | max_y = 0; 18 | } 19 | 20 | Rectangle::Rectangle(int min_x, int min_y, int max_x, int max_y) { 21 | this->resize(min_x, min_y, max_x, max_y); 22 | } 23 | 24 | void Rectangle::resize(int min_x, int min_y, int max_x, int max_y) { 25 | this->min_x = min_x; 26 | this->min_y = min_y; 27 | this->max_x = max_x; 28 | this->max_y = max_y; 29 | } 30 | 31 | void Rectangle::intersect(int min_x, int min_y, int max_x, int max_y) { 32 | this->min_x = this->min_x > min_x ? this->min_x : min_x; 33 | this->min_y = this->min_y > min_y ? this->min_y : min_y; 34 | this->max_x = this->max_x < max_x ? this->max_x : max_x; 35 | this->max_y = this->max_y < max_y ? this->max_y : max_y; 36 | } 37 | 38 | }; // namespace acid_maps 39 | 40 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/error/AcidMapException.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.error; 2 | 3 | // TODO: Auto-generated Javadoc 4 | /** 5 | * This exception is thrown when an AcidMap error occurs. 6 | */ 7 | public class AcidMapException extends Exception { 8 | 9 | /** 10 | * Instantiates a new acid map exception. 11 | */ 12 | public AcidMapException() { 13 | super(); 14 | } 15 | 16 | /** 17 | * Instantiates a new acid map exception. 18 | * 19 | * @param message the message 20 | * @param cause the cause 21 | */ 22 | public AcidMapException(String message, Throwable cause) { 23 | super(message, cause); 24 | } 25 | 26 | /** 27 | * Instantiates a new acid map exception. 28 | * 29 | * @param message the message 30 | */ 31 | public AcidMapException(String message) { 32 | super(message); 33 | } 34 | 35 | /** 36 | * Instantiates a new acid map exception. 37 | * 38 | * @param cause the cause 39 | */ 40 | public AcidMapException(Throwable cause) { 41 | super(cause); 42 | } 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ams/src/simplify/grid_simplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_SIMPLIFY_GRID_SIMPLIFIER_H_ 2 | #define LIB_SOURCE_SIMPLIFY_GRID_SIMPLIFIER_H_ 3 | /** 4 | * @file grid_simplifier.h 5 | * @brief Grid simplifier implementation 6 | * 7 | * A double pass simplification 8 | * The first step it iterates through the complete dataset 9 | * calculating the bounding box and generates a grid 10 | * 11 | * The second step iterates through the dataset acummulating its 12 | * value in the grid 13 | * 14 | * The third step we calculate the average 15 | * 16 | * @date 2011-01-12 17 | * @authors Fabio R. Panettieri 18 | */ 19 | 20 | #include "./simplifier.h" 21 | 22 | namespace acid_maps { 23 | 24 | /** 25 | * @brief Keeps the dataset untouched 26 | */ 27 | class GridSimplifier : public Simplifier { 28 | /** 29 | * @brief It does nothing with the dataset 30 | */ 31 | void simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size); 32 | }; 33 | 34 | }; // namespace acid_maps 35 | 36 | #endif // LIB_SOURCE_SIMPLIFY_GRID_SIMPLIFIER_H_ 37 | 38 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/core/Bounds.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.core; 2 | 3 | // TODO: Auto-generated Javadoc 4 | /** 5 | * @date 09/11/2010 6 | * @author cfarina 7 | * 8 | * Bounding Box representation Instances of this class represent bounding 9 | * boxes. Data stored as left, bottom, right, top floats. All values are 10 | * initialized to 0, however, you should make sure you set them before 11 | * using the bounds for anything. 12 | */ 13 | public class Bounds { 14 | 15 | /** The min x. */ 16 | public float minX; 17 | 18 | /** The min y. */ 19 | public float minY; 20 | 21 | /** The max x. */ 22 | public float maxX; 23 | 24 | /** The max y. */ 25 | public float maxY; 26 | 27 | public Bounds() { 28 | } 29 | 30 | /** 31 | * @param minX 32 | * @param minY 33 | * @param maxX 34 | * @param maxY 35 | */ 36 | public Bounds(float minX, float minY, float maxX, float maxY) { 37 | super(); 38 | this.minX = minX; 39 | this.minY = minY; 40 | this.maxX = maxX; 41 | this.maxY = maxY; 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /ams/src/render/renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_RENDER_RENDERER_H_ 2 | #define LIB_SOURCE_RENDER_RENDERER_H_ 3 | /** 4 | * @file transformer.h 5 | * @brief Transformer definition 6 | * 7 | * @date 2010-11-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * Forward declaration 15 | */ 16 | struct Size; 17 | struct Color; 18 | 19 | /** 20 | * @brief Renders the raw image 21 | */ 22 | class Renderer { 23 | public: 24 | /** 25 | * @brief Virtual destructor allows proper destructor calls 26 | */ 27 | virtual ~Renderer(){}; 28 | /** 29 | * @brief After the interpolated bitmap has been generated, the renderer generates 30 | * an image that represents that bitmap 31 | */ 32 | virtual void render(float interpolated_bitmap[], Size* tile_size, float intervals[], 33 | int intervals_size, Color* intervals_colors, unsigned char* output_buffer) = 0; 34 | 35 | virtual int interval(float value, float intervals[], int intervals_size) = 0; 36 | }; 37 | 38 | }; // namespace acid_maps 39 | 40 | #endif // LIB_SOURCE_RENDER_RENDERER_H_ 41 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/.actionScriptProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/error/Validator.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.error; 2 | 3 | import com.xoomcode.acidmaps.core.Configuration; 4 | 5 | public class Validator { 6 | 7 | public static int validate(Configuration cfg) { 8 | if(cfg.dataset == null || cfg.dataset.length == 0) return 1; 9 | if(cfg.datasetSize < 0) return 2; 10 | if(cfg.simplifyMethod < 0 || cfg.simplifyMethod > 3) return 3; 11 | if(cfg.simplifySize < 0) return 4; 12 | if(cfg.bounds == null) return 5; 13 | if(cfg.interpolationStrategy < 0 || cfg.interpolationStrategy > 3) return 6; 14 | if(cfg.radius < 0) return 7; 15 | if(cfg.width < 0 || cfg.height < 0) return 8; 16 | if(cfg.intervals == null || cfg.intervals.length == 0) return 9; 17 | if(cfg.intervalsColors == null || cfg.intervalsColors.length == 0) return 10; 18 | if(cfg.rendererType < 0 || cfg.rendererType > 3) return 12; 19 | if(cfg.format < 0 || cfg.format > 0) return 13; 20 | for(int i = 0; i < cfg.intervals.length - 1; i++){ 21 | if(cfg.intervals[i] >= cfg.intervals[i + 1]) return 14; 22 | } 23 | return 0; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /ams/test/render/gradient_renderer_intervals_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../../src/render/gradient_renderer.h" 6 | 7 | class GradientRendererIntervalsTest : public CppUnit::TestFixture { 8 | CPPUNIT_TEST_SUITE(GradientRendererIntervalsTest); 9 | CPPUNIT_TEST( firstInterval ); 10 | CPPUNIT_TEST_SUITE_END(); 11 | 12 | public: 13 | void setUp() { 14 | std::srand((unsigned)std::time(0)); 15 | 16 | renderer = new acid_maps::GradientRenderer(); 17 | intervals_size = std::rand() % 10 + 5; 18 | intervals = new float[intervals_size]; 19 | for (int i = 0; i < intervals_size; i++) { 20 | intervals[i] = (i + 1) * 10; 21 | } 22 | } 23 | 24 | void tearDown() { 25 | delete renderer; 26 | delete[] intervals; 27 | } 28 | 29 | void firstInterval () { 30 | CPPUNIT_ASSERT_EQUAL(0, renderer->interval(9, intervals, intervals_size)); 31 | } 32 | 33 | private: 34 | acid_maps::Renderer* renderer; 35 | float* intervals; 36 | int intervals_size; 37 | }; 38 | 39 | CPPUNIT_TEST_SUITE_REGISTRATION( GradientRendererIntervalsTest ); 40 | -------------------------------------------------------------------------------- /ams/src/interpolate/interpolation.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_INTERPOLATE_INTERPOLATION_H_ 2 | #define LIB_SOURCE_INTERPOLATE_INTERPOLATION_H_ 3 | /** 4 | * @file interpolation.h 5 | * @brief Interpolation base class 6 | * 7 | * It defines the interpolate method that must be implemented by all it's subclasses 8 | * 9 | * @date 2010-11-03 10 | * @authors Fabio R. Panettieri 11 | */ 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * Forward declaration 17 | */ 18 | struct Size; 19 | struct Pixel; 20 | 21 | /** 22 | * @brief Interpolation's base class 23 | * 24 | * You should not use this class directly. 25 | * Use InterpolationFactory if you want an instance of any subclass 26 | */ 27 | class Interpolation { 28 | public: 29 | /** 30 | * @brief Virtual destructor allows proper destructor calls 31 | */ 32 | virtual ~Interpolation(){}; 33 | 34 | /** 35 | * @brief Generates an interpolated int bitmap 36 | */ 37 | virtual void interpolate(Size* tile_size, Pixel* dataset, int dataset_size, int radius, float interpolated_bitmap[]) = 0; 38 | }; 39 | 40 | }; // namespace acid_maps 41 | 42 | #endif // LIB_SOURCE_INTERPOLATE_INTERPOLATION_H_ 43 | 44 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/cache/Dataset.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.xoomcode.acidmaps.cache; 5 | 6 | import java.util.Date; 7 | 8 | import com.xoomcode.acidmaps.core.Point; 9 | 10 | /** 11 | * 12 | * @date 11/11/2010 13 | * @author cfarina 14 | * 15 | * It Saves the points cached by DatasetCache. 16 | */ 17 | public class Dataset { 18 | 19 | private Point[] dataset; 20 | 21 | private Date date = new Date(); 22 | 23 | /** 24 | * @param timer 25 | * @param dataset 26 | */ 27 | public Dataset(Point[] dataset) { 28 | this.dataset = dataset; 29 | } 30 | 31 | /** 32 | * @param date This property is used to invalidate 33 | * the dataset when is cached. 34 | */ 35 | public void setDate(Date date) { 36 | this.date = date; 37 | } 38 | 39 | /** 40 | * @return the date 41 | */ 42 | public Date getDate() { 43 | return date; 44 | } 45 | 46 | /** 47 | * @return the dataset 48 | */ 49 | public Point[] getDataset() { 50 | return dataset; 51 | } 52 | 53 | /** 54 | * @param dataset the dataset to set 55 | */ 56 | public void setDataset(Point[] dataset) { 57 | this.dataset = dataset; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /ams/src/simplify/simplifier.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_SIMPLIFY_SIMPLIFIER_H_ 2 | #define LIB_SOURCE_SIMPLIFY_SIMPLIFIER_H_ 3 | /** 4 | * @file simplifier.h 5 | * @brief Simplifiers base class 6 | * 7 | * It defines the simplify method that must be implemented by all it's subclasses 8 | * 9 | * @date 2010-11-03 10 | * @authors Fabio R. Panettieri 11 | */ 12 | 13 | namespace acid_maps { 14 | 15 | /** 16 | * Forward declaration 17 | */ 18 | struct Configuration; 19 | struct Point; 20 | 21 | /** 22 | * @brief Simplifier's base class 23 | * 24 | * You should not use this class directly. 25 | * Use SimplifierFactory if you want an instance of any subclass 26 | */ 27 | class Simplifier { 28 | public: 29 | /** 30 | * @brief Virtual destructor allows proper destructor calls 31 | */ 32 | virtual ~Simplifier(){}; 33 | 34 | /** 35 | * @brief Reduce the number of valued points 36 | * 37 | * @param simplified_dataset float Output buffer 38 | */ 39 | virtual void simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size) = 0; 40 | }; 41 | 42 | }; // namespace acid_maps 43 | 44 | #endif // LIB_SOURCE_SIMPLIFY_SIMPLIFIER_H_ 45 | 46 | -------------------------------------------------------------------------------- /ams/src/core/validator.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file validator.cc 3 | * @brief Validates the configuration 4 | * 5 | * @date 2011-03-04 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "./validator.h" 10 | #include "./configuration.h" 11 | 12 | #include 13 | 14 | namespace acid_maps { 15 | 16 | int Validator::validate(Configuration* cfg) { 17 | 18 | if(cfg->dataset == NULL) return 1; 19 | if(cfg->dataset_size < 0) return 2; 20 | if(cfg->simplify_method < 0 || cfg->simplify_method > 3) return 3; 21 | if(cfg->simplify_size < 0) return 4; 22 | if(cfg->bounds == NULL) return 5; 23 | if(cfg->interpolation_strategy < 0 || cfg->interpolation_strategy > 3) return 6; 24 | if(cfg->radius < 0) return 7; 25 | if(cfg->tile_size == NULL) return 8; 26 | if(cfg->intervals == NULL) return 9; 27 | if(cfg->intervals_colors == NULL) return 10; 28 | if(cfg->intervals_size <= 0) return 11; 29 | if(cfg->renderer_type < 0 || cfg->renderer_type > 3) return 12; 30 | if(cfg->format < 0 || cfg->format > 0) return 13; 31 | for(int i = 0; i < cfg->intervals_size - 1; i++){ 32 | if(cfg->intervals[i] >= cfg->intervals[i + 1]) return 14; 33 | } 34 | 35 | return 0; 36 | } 37 | 38 | }; // namespace acid_maps 39 | 40 | -------------------------------------------------------------------------------- /ams/src/render/dense_renderer.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dense_renderer.cc 3 | * 4 | * @date 2011-03-14 5 | * @authors Fabio R. Panettieri 6 | */ 7 | 8 | #include "../constants/constants.h" 9 | #include "../core/color.h" 10 | #include "../core/configuration.h" 11 | #include "../core/size.h" 12 | #include "./dense_renderer.h" 13 | #include 14 | 15 | namespace acid_maps { 16 | 17 | /** 18 | * @todo Marching squares 19 | */ 20 | void DenseRenderer::render(float interpolated_bitmap[], Size* tile_size, float intervals[], 21 | int intervals_size, Color* intervals_colors, unsigned char* output_buffer) { 22 | int interval_index; 23 | int bitmap_size = tile_size->width * tile_size->height; 24 | 25 | for (unsigned int i = 0; i < bitmap_size; i++) { 26 | interval_index = this->interval(interpolated_bitmap[i], intervals, intervals_size); 27 | std::memcpy(output_buffer + i * RGBA, intervals_colors + interval_index, sizeof(Color)); 28 | } 29 | } 30 | 31 | int DenseRenderer::interval(float value, float intervals[], int intervals_size) { 32 | if(value < 0) return 0; 33 | if(value >= intervals_size) return intervals_size - 1; 34 | return (int)value; 35 | } 36 | 37 | 38 | }; // namespace acid_maps 39 | 40 | -------------------------------------------------------------------------------- /geoserver/plugin/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/constants/ErrorConstants.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.constants; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class ErrorConstants { 7 | 8 | public static Map map = new HashMap(); 9 | 10 | static { 11 | map.put(1, "dataset is null."); 12 | map.put(2, "dataset size is 0."); 13 | map.put(3, "Simplify method is lower than 0 or greater than 3."); 14 | map.put(4, "Simplify size is lower than 0 or greater than dataset size."); 15 | map.put(5, "bounds is null."); 16 | map.put(6, "Interpolation strategy is lower than 0 or greater than 3."); 17 | map.put(7, "Radius is lower than 0."); 18 | map.put(8, "Tile size is null."); 19 | map.put(9, "Intervals is null."); 20 | map.put(10, "Intervals colors is null."); 21 | map.put(11, "Intervals size is null."); 22 | map.put(12, "Renderer type is lower than 1 or greater than 3."); 23 | map.put(13, "Format isn't equal to 0."); 24 | map.put(14, "Malformed range."); 25 | } 26 | 27 | public static String getErrorString(Integer code){ 28 | if(map.get(code) == null){ 29 | return "Unknow error."; 30 | } else { 31 | return map.get(code); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ams/src/transform/transformer.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file transformer.cc 3 | * @brief Transformer implementation 4 | * 5 | * @date 2010-11-03 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "../constants/constants.h" 10 | #include "../core/bounds.h" 11 | #include "../core/configuration.h" 12 | #include "../core/point.h" 13 | #include "../core/pixel.h" 14 | #include "./transformer.h" 15 | 16 | namespace acid_maps { 17 | 18 | /** 19 | * @ todo Store pixel positions in int* 20 | */ 21 | void Transformer::transform(Bounds* bounds, Size* tile_size, Point dataset[], 22 | int dataset_size, Pixel transformed_dataset[]) { 23 | 24 | float bounds_width = bounds->max_x - bounds->min_x; 25 | float bounds_height = bounds->max_y - bounds->min_y; 26 | 27 | float horizontal_resolution = bounds_width / tile_size->width; 28 | float vertical_resolution = bounds_height / tile_size->height; 29 | 30 | Pixel* pixel; 31 | Point* point; 32 | for (int i = 0; i < dataset_size; i++) { 33 | point = dataset + i; 34 | pixel = transformed_dataset + i; 35 | 36 | pixel->x = (int)((point->x - bounds->min_x) / horizontal_resolution); 37 | pixel->y = (int)((bounds->max_y - point->y) / vertical_resolution); 38 | pixel->value = point->value; 39 | } 40 | } 41 | 42 | }; // namespace acid_maps 43 | 44 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | Use the same filter factory declared in the WFS module 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | GetMap 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/core/Configuration.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.core; 2 | 3 | // TODO: Auto-generated Javadoc 4 | /** 5 | * @date 09/11/2010 6 | * @author cfarina 7 | * Configuration is used to send AMS parameters to the C++ AMS library. 8 | */ 9 | public class Configuration { 10 | 11 | /** Set of valued points, stored 3 floats per point. X, Y, Value */ 12 | public Point[] dataset; 13 | 14 | public int datasetSize; 15 | 16 | /** Desired simplify method. */ 17 | public int simplifyMethod; 18 | 19 | /** Size of the simplified sample. */ 20 | public int simplifySize; 21 | 22 | /** Requested tile bounds. */ 23 | public Bounds bounds; 24 | 25 | /** Strategy used to interpolate missing values. */ 26 | public int interpolationStrategy; 27 | 28 | /** Output image width. */ 29 | public int width; 30 | 31 | /** Output image height. */ 32 | public int height; 33 | 34 | /** Radius for every interpolation type. */ 35 | public int radius; 36 | 37 | public float[] intervals; 38 | 39 | public Color[] intervalsColors; 40 | 41 | public int intervalsSize; 42 | 43 | public int rendererType; 44 | 45 | public int format; 46 | 47 | public int error; 48 | 49 | /** 50 | * Instantiates a new configuration. 51 | */ 52 | public Configuration() { 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ams/src/interpolate/nearest_neighbor.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nearest_neighbor.cc 3 | * @brief Nearest Neighbor interpolation implementation 4 | * 5 | * @date 2010-11-09 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "../constants/constants.h" 10 | #include "../core/size.h" 11 | #include "../core/pixel.h" 12 | #include "./nearest_neighbor.h" 13 | #include 14 | #include 15 | #include 16 | 17 | namespace acid_maps { 18 | 19 | /** 20 | * @todo use the parameter 21 | * @todo marching squares 22 | */ 23 | void NearestNeighbor::interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 24 | int radius, float interpolated_bitmap[]) { 25 | 26 | Pixel* pixel; 27 | float minimum_distance, distance_x, distance_y, distance; 28 | for (int y = 0; y < tile_size->height; y++) { 29 | for (int x = 0; x < tile_size->width; x++) { 30 | 31 | minimum_distance = INT_MAX; 32 | for (int i = 0; i < dataset_size; i++) { 33 | pixel = dataset + i; 34 | distance_x = x - pixel->x; 35 | distance_y = y - pixel->y; 36 | distance = std::sqrt(std::pow(distance_x, 2) + std::pow(distance_y, 2)); 37 | 38 | if (distance < minimum_distance) { 39 | minimum_distance = distance; 40 | interpolated_bitmap[y * tile_size->width + x] = pixel->value; 41 | } 42 | } 43 | } 44 | } 45 | 46 | } 47 | 48 | }; // namespace acid_maps 49 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/src/RangeItem.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ams/src/core/configuration.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_CONFIGURATION_H_ 2 | #define LIB_SOURCE_CONFIGURATION_H_ 3 | /** 4 | * @file configuration.h 5 | * @brief 6 | * 7 | * @date 2010-11-02 8 | * @authors Fabio R. Panettieri 9 | * 10 | * @todo Brief and description 11 | * 12 | */ 13 | 14 | #include "./color.h" 15 | #include "./point.h" 16 | #include "./bounds.h" 17 | #include "./size.h" 18 | 19 | namespace acid_maps { 20 | 21 | /** 22 | * @brief 23 | * 24 | * @todo Brief and description 25 | */ 26 | struct Configuration { 27 | /// Set of valued points, stored 3 floats per point. X, Y, Value 28 | Point* dataset; 29 | 30 | /// Number of points in the dataset 31 | int dataset_size; 32 | 33 | /// Desired simplify method 34 | int simplify_method; 35 | 36 | /// Size of the simplified sample 37 | int simplify_size; 38 | 39 | /// Requested tile bounds 40 | Bounds* bounds; 41 | 42 | /// Strategy used to interpolate missing values 43 | int interpolation_strategy; 44 | 45 | /// Radius 46 | int radius; 47 | 48 | /// Output image size 49 | Size* tile_size; 50 | 51 | /// Intervals array 52 | float* intervals; 53 | 54 | /// Intervals array 55 | Color* intervals_colors; 56 | 57 | /// Size of the itervals array 58 | int intervals_size; 59 | 60 | /// Determines how intervals are going to be accessed in the rendering step 61 | int renderer_type; 62 | 63 | /// Image format 64 | int format; 65 | }; 66 | 67 | }; // namespace acid_maps 68 | 69 | #endif // LIB_SOURCE_CONFIGURATION_H_ 70 | 71 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/adapter/JCAdapter.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.adapter; 2 | 3 | import com.xoomcode.acidmaps.constants.ErrorConstants; 4 | import com.xoomcode.acidmaps.core.Configuration; 5 | import com.xoomcode.acidmaps.error.AcidMapException; 6 | 7 | // TODO: Auto-generated Javadoc 8 | /** 9 | * 10 | * This class allows communication between geoserver plugin and 11 | * acid map library, which is developed in C++. 12 | * 13 | * @date 09/11/2010 14 | * @author cfarina 15 | */ 16 | public class JCAdapter { 17 | 18 | /** 19 | * 20 | */ 21 | public JCAdapter() { 22 | // TODO Auto-generated constructor stub 23 | } 24 | 25 | /** 26 | * Interpolate c. 27 | * 28 | * @param configuration the configuration 29 | * @param out the out 30 | */ 31 | private native Object interpolateC(Configuration configuration); 32 | 33 | static { 34 | // The runtime system executes a class's static 35 | // initializer when it loads the class. 36 | System.loadLibrary("acid-maps-jni"); 37 | } 38 | 39 | /** 40 | * Interpolate. 41 | * 42 | * @param configuration the configuration 43 | * @param out the out 44 | * @throws AcidMapException 45 | */ 46 | public byte[] interpolate(Configuration configuration) throws AcidMapException{ 47 | Object interpolateC = interpolateC(configuration); 48 | 49 | if(interpolateC == null){ 50 | throw new AcidMapException("Opaaa. Error in acidMapsLibrary. " + ErrorConstants.getErrorString(configuration.error)); 51 | } 52 | 53 | if(interpolateC instanceof byte[]){ 54 | return (byte[])interpolateC; 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /ams/src/interpolate/inverse_distance_weighting.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file inverse_distance_weighting.cc 3 | * @brief Inverse Distance Weighted Interpolation 4 | * 5 | * @date 2011-01-05 6 | 7 | * @authors Fabio R. Panettieri 8 | */ 9 | 10 | #include "./inverse_distance_weighting.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "../constants/constants.h" 16 | #include "../core/size.h" 17 | #include "../core/pixel.h" 18 | #include "../core/rectangle.h" 19 | 20 | namespace acid_maps { 21 | 22 | /** 23 | * @todo 24 | */ 25 | void InverseDistanceWeighting::interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 26 | int radius, float interpolated_bitmap[]) { 27 | Pixel* pixel; 28 | float distance_x, distance_y, weight, accummulated_value, accummulated_weight; 29 | for (int y = 0; y < tile_size->height; y++) { 30 | for (int x = 0; x < tile_size->width; x++) { 31 | accummulated_value = 0; 32 | accummulated_weight = 0; 33 | for (int i = 0; i < dataset_size; i++) { 34 | pixel = dataset + i; 35 | distance_x = static_cast(x - pixel->x); 36 | distance_y = static_cast(y - pixel->y); 37 | if (distance_x == 0 && distance_y == 0) { 38 | weight = 1.0f; 39 | } else { 40 | weight = 1.0f / (std::pow(distance_x, 2.0f) + std::pow(distance_y, 2.0f)); 41 | } 42 | accummulated_value += pixel->value * weight; 43 | accummulated_weight += weight; 44 | } 45 | interpolated_bitmap[y * tile_size->width + x] = accummulated_value / accummulated_weight; 46 | } 47 | } 48 | } 49 | 50 | }; // namespace acid_maps 51 | 52 | -------------------------------------------------------------------------------- /ams/src/interpolate/dummy_interpolation.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dummy_interpolation.cc 3 | * @brief Dummy interpolation implementation 4 | * 5 | * @date 2010-11-03 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "../constants/constants.h" 10 | #include "../core/size.h" 11 | #include "../core/pixel.h" 12 | #include "../core/rectangle.h" 13 | #include "./dummy_interpolation.h" 14 | #include 15 | #include 16 | 17 | namespace acid_maps { 18 | 19 | /** 20 | * @todo use the parameter 21 | */ 22 | void DummyInterpolation::interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 23 | int radius, float interpolated_bitmap[]) { 24 | std::memset(interpolated_bitmap, 0, tile_size->width * tile_size->height * sizeof(interpolated_bitmap[0])); 25 | 26 | Rectangle bounds; 27 | Pixel* pixel; 28 | float distance_x, distance_y, distance; 29 | for (int i = 0; i < dataset_size; i++) { 30 | pixel = dataset + i; 31 | 32 | bounds.resize(0, 0, tile_size->width, tile_size->height); 33 | bounds.intersect(pixel->x - radius, pixel->y - radius, pixel->x + radius, pixel->y + radius); 34 | 35 | for (int y = bounds.min_y; y < bounds.max_y; y++) { 36 | for (int x = bounds.min_x; x < bounds.max_x; x++) { 37 | distance_x = (float)(x - pixel->x); 38 | distance_y = (float)(y - pixel->y); 39 | distance = std::sqrt(std::pow(distance_x, 2.0f) + std::pow(distance_y, 2.0f)); 40 | 41 | if (distance < radius) { 42 | interpolated_bitmap[y * tile_size->width + x] = pixel->value; 43 | } 44 | } 45 | } 46 | } 47 | 48 | } 49 | 50 | }; // namespace acid_maps 51 | 52 | -------------------------------------------------------------------------------- /ams/src/interpolate/linear_interpolation.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file linear_interpolation.cc 3 | * @brief Linear interpolation implementation 4 | * 5 | * @date 2010-11-09 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include "./linear_interpolation.h" 10 | 11 | #include 12 | #include 13 | 14 | #include "../constants/constants.h" 15 | #include "../core/size.h" 16 | #include "../core/pixel.h" 17 | #include "../core/rectangle.h" 18 | 19 | namespace acid_maps { 20 | 21 | /** 22 | * @todo REFACTOR THIS IN MULTIPLE FUNCTIONS 23 | */ 24 | void LinearInterpolation::interpolate(Size* tile_size, Pixel* dataset, int dataset_size, 25 | int radius, float interpolated_bitmap[]) { 26 | std::memset(interpolated_bitmap, 0, tile_size->width * tile_size->height * sizeof(interpolated_bitmap[0])); 27 | 28 | Rectangle bounds; 29 | Pixel* pixel; 30 | float distance_x, distance_y, distance; 31 | for (int i = 0; i < dataset_size; i++) { 32 | pixel = dataset + i; 33 | bounds.resize(0, 0, tile_size->width, tile_size->height); 34 | bounds.intersect(pixel->x - radius, pixel->y - radius, pixel->x + radius, pixel->y + radius); 35 | for (int y = bounds.min_y; y < bounds.max_y; y++) { 36 | for (int x = bounds.min_x; x < bounds.max_x; x++) { 37 | distance_x = static_cast(x - pixel->x); 38 | distance_y = static_cast(y - pixel->y); 39 | distance = std::sqrt(std::pow(distance_x, 2.0f) + std::pow(distance_y, 2.0f)); 40 | if (distance < radius) { 41 | interpolated_bitmap[y * tile_size->width + x] += pixel->value * (1.0f - distance / radius); 42 | } 43 | } 44 | } 45 | } 46 | } 47 | 48 | }; // namespace acid_maps 49 | 50 | -------------------------------------------------------------------------------- /ams/src/render/sparse_renderer.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sparse_renderer.cc 3 | * 4 | * @date 2010-11-08 5 | * @authors Fabio R. Panettieri 6 | */ 7 | 8 | #include "../constants/constants.h" 9 | #include "../core/color.h" 10 | #include "../core/configuration.h" 11 | #include "../core/size.h" 12 | #include "./sparse_renderer.h" 13 | #include 14 | 15 | namespace acid_maps { 16 | 17 | /** 18 | * @todo Marching squares 19 | */ 20 | void SparseRenderer::render(float interpolated_bitmap[], Size* tile_size, float intervals[], 21 | int intervals_size, Color* intervals_colors, unsigned char* output_buffer) { 22 | int interval_index; 23 | int bitmap_size = tile_size->width * tile_size->height; 24 | 25 | for (unsigned int i = 0; i < bitmap_size; i++) { 26 | interval_index = this->interval(interpolated_bitmap[i], intervals, intervals_size); 27 | std::memcpy(output_buffer + i * RGBA, intervals_colors + interval_index, sizeof(Color)); 28 | } 29 | } 30 | 31 | int SparseRenderer::interval(float value, float intervals[], int intervals_size) { 32 | int first = 0; 33 | int last = intervals_size - 1; 34 | int mid = 0; 35 | 36 | if (value < intervals[first]) { 37 | return first; 38 | } else if (value >= intervals[last]) { 39 | return last; 40 | } 41 | 42 | while (first <= last) { 43 | mid = (first + last) / 2; 44 | if (value > intervals[mid]) { 45 | first = mid + 1; 46 | } else if (value < intervals[mid]) { 47 | if (mid >= 1 && value > intervals[mid - 1]) { 48 | return mid; 49 | } else { 50 | last = mid - 1; 51 | } 52 | } else { 53 | return mid; 54 | } 55 | } 56 | 57 | // HACK: changed -1 to avoid segmentation faults. 58 | // This error should be made explicit 59 | return 0; 60 | } 61 | 62 | 63 | }; // namespace acid_maps 64 | 65 | -------------------------------------------------------------------------------- /ams/src/acid_maps.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_ACID_MAPS_H_ 2 | #define LIB_SOURCE_ACID_MAPS_H_ 3 | /** 4 | * @mainpage Acid Maps core library 5 | * 6 | * @file acid_maps.h 7 | * @brief Acid Maps public interface 8 | * 9 | * Acid Maps images are generated through the following method 10 | * 11 | * Simplify -> Transform -> Interpolate -> Render 12 | * 13 | * Simplify: Acid Maps can interpolate very large datasets. 14 | * In order to keep the proccess stable and fast execution times, its very important to 15 | * simplify them to smaller sizes. 16 | * This proccess generates simplified datasets. 17 | * 18 | * Transform: Datasets contains projected information. 19 | * In order to improve the interpolation proccess and allow a proper rendering 20 | * they are transformed to pixels coordinates from the top-left corner of the image. 21 | * 22 | * Interpolate: In order to generate raster images from a discrete set of points 23 | * missing values are generated through different interpolation strategy. 24 | * 25 | * Render: After the interpolated bitmap has been generated, the renderer generates 26 | * an image that represents that bitmap 27 | * 28 | * @date 2010-11-02 29 | * @authors Fabio R. Panettieri 30 | */ 31 | 32 | namespace acid_maps { 33 | 34 | /** 35 | * Configuration forward declaration 36 | */ 37 | struct Configuration; 38 | 39 | /** 40 | * @brief Generates an interpolated raster with the given configuration 41 | * 42 | * This is Acid Maps public interface 43 | * Generates a raw raster image based on the given configuration. 44 | * 45 | * @param configuration Configuration 46 | * @param output_buffer char* a 32bits raw image will stored here 47 | */ 48 | int generate(Configuration* configuration, unsigned char** output_buffer, unsigned int* output_size); 49 | 50 | }; // namespace acid_maps 51 | 52 | #endif // LIB_SOURCE_ACID_MAPS_H_ 53 | 54 | -------------------------------------------------------------------------------- /ams/src/transform/transformer.h: -------------------------------------------------------------------------------- 1 | #ifndef LIB_SOURCE_TRANSFORM_TRANSFORMER_H_ 2 | #define LIB_SOURCE_TRANSFORM_TRANSFORMER_H_ 3 | /** 4 | * @file transformer.h 5 | * @brief Transformer definition 6 | * 7 | * @date 2010-11-03 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | namespace acid_maps { 12 | 13 | /** 14 | * Forward declarations 15 | */ 16 | struct Point; 17 | struct Pixel; 18 | 19 | class Transformer { 20 | public: 21 | /** 22 | * @brief Transform each point geographic coordinates 23 | * in the dataset to pixel coordinates from the top-left corner of the image. 24 | * 25 | * * The configuration parameter contains a dataset member that is an array of Valued Points (VP). 26 | * Each VP is actually a set of 3 floats: 27 | * x: Horizontal position of the point in a geographic Spatial Reference System (SRS) 28 | * y: Vertical position of the point in a SRS 29 | * v: Value or Weight of that point 30 | * 31 | * In order to interpolate and render our dataset, we need to convert 32 | * those points to a more screen friendly coordinate system. 33 | * Thus, points coordinates are transformed into pixel distance from the top left corner of the pixel 34 | * 35 | * WORLD 0,0 px 36 | * |------------| |-----------| 37 | * | |---o x,y | | | 38 | * | | | | | | | 39 | * |------------| ---> | | | 40 | * | |0,0 | |------o px,py 41 | * | | | | | 42 | * |------------| |-----------| 43 | * TILE 44 | */ 45 | void transform(Bounds* bounds, Size* tile_size, Point* dataset, int dataset_size, Pixel* transformed_dataset); 46 | }; 47 | 48 | }; // namespace acid_maps 49 | 50 | #endif // LIB_SOURCE_TRANSFORM_TRANSFORMER_H_ 51 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/error/ErrorImageFactory.java: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps.error; 2 | 3 | import java.awt.Font; 4 | import java.awt.FontMetrics; 5 | import java.awt.Graphics2D; 6 | import java.awt.image.BufferedImage; 7 | 8 | public class ErrorImageFactory { 9 | 10 | public BufferedImage getErrorImage(int width, int height, String message) { 11 | 12 | BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 13 | 14 | // Create a graphics contents on the buffered image 15 | Graphics2D g2d = image.createGraphics(); 16 | 17 | // Draw graphics 18 | g2d.setColor(java.awt.Color.white); 19 | g2d.fillRect(0, 0, width, height); 20 | // g2d.setColor(java.awt.Color.gray); 21 | // g2d.drawRect(0, 0, width, height); 22 | g2d.setColor(java.awt.Color.black); 23 | g2d.setFont(new Font("SansSerif", Font.BOLD, 12 )); 24 | 25 | FontMetrics fm = g2d.getFontMetrics(); 26 | int textWidth = fm.stringWidth(message); 27 | int parts = (int)Math.ceil(textWidth / (width * 1.0)); 28 | int partLength = message.length() / parts; 29 | int lineHeight = 20; 30 | 31 | int from = 0; 32 | int to = 0; 33 | int cursor = 0; 34 | int i = 0; 35 | do { 36 | from = cursor; 37 | to = from + partLength; 38 | if(to >= message.length()){ 39 | to = message.length(); 40 | } 41 | String part = message.substring(from, to); 42 | int lastSpaceIndex = part.lastIndexOf(" "); 43 | if(lastSpaceIndex == 0){ 44 | lastSpaceIndex = part.length(); 45 | } 46 | String fixedPart; 47 | if(lastSpaceIndex != -1){ 48 | fixedPart = part.substring(0, lastSpaceIndex); 49 | } else { 50 | fixedPart = part; 51 | lastSpaceIndex = part.length(); 52 | } 53 | g2d.drawString(fixedPart.trim(), 5, 10 + lineHeight* (i + 1)); 54 | cursor += lastSpaceIndex; 55 | i++; 56 | }while(cursor < message.length() || (i * lineHeight > height)); 57 | 58 | // Graphics context no longer needed so dispose it 59 | g2d.dispose(); 60 | return image; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/cache/DatasetCacheKey.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.xoomcode.acidmaps.cache; 5 | 6 | 7 | /** 8 | * @date 11/11/2010 9 | * @author cfarina 10 | * 11 | * Every cached data is identify by an unique key. This key is 12 | * formed by the layer name and the CQLFilter. 13 | */ 14 | public class DatasetCacheKey { 15 | 16 | private String layer; 17 | 18 | private String filter; 19 | 20 | private int filterHash; 21 | 22 | /** 23 | * @param layer 24 | */ 25 | public DatasetCacheKey(String layer, String filter) { 26 | super(); 27 | this.layer = layer; 28 | this.filter = filter; 29 | filterHash = filter.hashCode(); 30 | } 31 | 32 | /** 33 | * @return the filter 34 | */ 35 | public String getFilter() { 36 | return filter; 37 | } 38 | 39 | /** 40 | * @param filter the filter to set 41 | */ 42 | public void setFilter(String filter) { 43 | this.filter = filter; 44 | } 45 | 46 | /** 47 | * @return the layer 48 | */ 49 | public String getLayer() { 50 | return layer; 51 | } 52 | 53 | /** 54 | * @param layer the layer to set 55 | */ 56 | public void setLayer(String layer) { 57 | this.layer = layer; 58 | } 59 | 60 | /* (non-Javadoc) 61 | * @see java.lang.Object#hashCode() 62 | */ 63 | @Override 64 | public int hashCode() { 65 | final int prime = 31; 66 | int result = 1; 67 | result = prime * result + filterHash; 68 | result = prime * result + ((layer == null) ? 0 : layer.hashCode()); 69 | return result; 70 | } 71 | 72 | /* (non-Javadoc) 73 | * @see java.lang.Object#equals(java.lang.Object) 74 | */ 75 | @Override 76 | public boolean equals(Object obj) { 77 | if (this == obj) 78 | return true; 79 | if (obj == null) 80 | return false; 81 | if (getClass() != obj.getClass()) 82 | return false; 83 | DatasetCacheKey other = (DatasetCacheKey) obj; 84 | if (filterHash != other.filterHash) 85 | return false; 86 | if (layer == null) { 87 | if (other.layer != null) 88 | return false; 89 | } else if (!layer.equals(other.layer)) 90 | return false; 91 | return true; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /examples/isolines/archsites.sld: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | archsites 5 | 6 | Arch Sites 7 | A sample style that draws a point 8 | 9 | 10 | 11 | 12 | 13 | circle 14 | 15 | #000000 16 | 17 | 18 | 10 19 | 20 | 21 | 22 | 25 | 26 | Arial 27 | 12 28 | normal 29 | bold 30 | 31 | 32 | 33 | 34 | 0.5 35 | 0.0 36 | 37 | 38 | 0 39 | 5 40 | 41 | 42 | 43 | 44 | #000000 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/src/RangeComponent.mxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 0){ 35 | var beforeItem:RangeItem = RangeItem(rangeItemContainer.getChildAt(rangeItemContainer.getChildren().length - 1)); 36 | newItem.value = beforeItem.numericStepper.value + 10; 37 | } 38 | rangeItemContainer.addChild(newItem); 39 | } 40 | 41 | public function getIntervals():Array { 42 | var intervals:Array = new Array(); 43 | for each(var item:RangeItem in rangeItemContainer.getChildren()){ 44 | intervals.push(item.value); 45 | } 46 | return intervals; 47 | } 48 | 49 | public function getColors():Array { 50 | var colors:Array = new Array(); 51 | for each(var item:RangeItem in rangeItemContainer.getChildren()){ 52 | var hexaNumber:uint = item.selectedAlpha * 0xFF; 53 | colors.push((item.selectedColor << 8) + hexaNumber); 54 | } 55 | return colors; 56 | 57 | } 58 | ]]> 59 | 60 | 61 | -------------------------------------------------------------------------------- /ams/src/simplify/extremes_simplifier.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file extremes_simplifier.cc 3 | * @brief Extremes simplifier implementation 4 | * 5 | * Find the maximum and minimum values 6 | * 7 | * @date 2011-01-27 8 | * @authors Fabio R. Panettieri 9 | */ 10 | 11 | #include "../constants/constants.h" 12 | #include "../core/point.h" 13 | #include "./extremes_simplifier.h" 14 | #include 15 | #include 16 | #include 17 | 18 | namespace acid_maps { 19 | 20 | void ExtremesSimplifier::simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size) { 21 | int min_limit = INT_MIN; 22 | int max_limit = INT_MAX; 23 | 24 | int minimum = INT_MAX; 25 | int maximum = INT_MIN; 26 | 27 | // Used to store extremes indexes 28 | int min_index, max_index; 29 | int* indexes = new int[simplify_size]; 30 | std::memset(indexes, -1, simplify_size * sizeof(indexes[0])); 31 | 32 | Point* point, *min, *max; 33 | for(int i = 0; i < simplify_size; i++){ 34 | 35 | float min_limit = INT_MIN; 36 | float max_limit = INT_MAX; 37 | 38 | float minimum = INT_MAX; 39 | float maximum = INT_MIN; 40 | 41 | for(int j = 0; j < dataset_size; j++){ 42 | if (in(j, indexes, simplify_size)) continue; 43 | 44 | point = dataset + j; 45 | if (point->value <= minimum && point->value >= min_limit){ 46 | minimum = point->value; 47 | min_index = j; 48 | 49 | } else if(point->value >= maximum && point->value <= max_limit) { 50 | maximum = point->value; 51 | max_index = j; 52 | } 53 | } 54 | 55 | // Lower limit 56 | indexes[i] = min_index; 57 | min = dataset + min_index; 58 | min_limit = min->value; 59 | std::memcpy(simplified_dataset + i, min, sizeof(Point)); 60 | 61 | // Exit if the array is full 62 | if(++i >= simplify_size) break; 63 | 64 | // Upper limit 65 | indexes[i] = max_index; 66 | max = dataset + max_index; 67 | max_limit = max->value; 68 | std::memcpy(simplified_dataset + i, max, sizeof(Point)); 69 | } 70 | 71 | delete[] indexes; 72 | 73 | } 74 | 75 | bool ExtremesSimplifier::in(int index, int* array, int array_size){ 76 | bool found = false; 77 | for(int i = 0; i < array_size; i++){ 78 | if(array[i] == index){ 79 | found = true; 80 | break; 81 | } 82 | } 83 | return found; 84 | } 85 | 86 | }; // namespace acid_maps 87 | 88 | -------------------------------------------------------------------------------- /geoserver/plugin/src/main/java/com/xoomcode/acidmaps/cache/DatasetCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package com.xoomcode.acidmaps.cache; 5 | 6 | import java.util.ArrayList; 7 | import java.util.Date; 8 | import java.util.Hashtable; 9 | import java.util.List; 10 | import java.util.Map; 11 | import java.util.Timer; 12 | import java.util.TimerTask; 13 | 14 | import com.xoomcode.acidmaps.core.Point; 15 | 16 | /** 17 | * @date 11/11/2010 18 | * @author cfarina 19 | * 20 | * Caches the data for a layer and a filter for a given time. When 21 | * the cached data is older than that given time, those data are removed. 22 | */ 23 | public class DatasetCache extends TimerTask { 24 | 25 | private Map cache = new Hashtable(); 26 | 27 | private Timer timer = new Timer(); 28 | 29 | public DatasetCache() { 30 | //Every a given time, the cache is cleaned 31 | timer.scheduleAtFixedRate(this, 0, 60000); 32 | } 33 | 34 | /** 35 | * @param datasetCacheKey 36 | * @return 37 | */ 38 | public boolean isCached(DatasetCacheKey datasetCacheKey) { 39 | return cache.get(datasetCacheKey) != null; 40 | } 41 | 42 | /** 43 | * @param datasetCacheKey 44 | */ 45 | public Point[] getDataset(DatasetCacheKey datasetCacheKey) { 46 | if(cache.get(datasetCacheKey) != null){ 47 | //cache.get(datasetCacheKey).setDate(new Date()); 48 | return cache.get(datasetCacheKey).getDataset(); 49 | } 50 | return null; 51 | } 52 | 53 | /** 54 | * @param datasetCacheKey 55 | * @param dataset 56 | */ 57 | public void put(DatasetCacheKey datasetCacheKey, Point[] dataset) { 58 | Dataset cachedDataset = new Dataset(dataset); 59 | cache.put(datasetCacheKey, cachedDataset); 60 | } 61 | 62 | /* (non-Javadoc) 63 | * @see java.util.TimerTask#run() 64 | */ 65 | @Override 66 | public void run() { 67 | List datasetCacheKeyForRemove = new ArrayList(); 68 | Date now = new Date(); 69 | for (DatasetCacheKey datasetCacheKey : cache.keySet()) { 70 | Dataset dataset = cache.get(datasetCacheKey); 71 | long delay = now.getTime() - dataset.getDate().getTime(); 72 | if(delay > 10000){ 73 | //if the cached data is older than the given limit time 74 | //this is removed 75 | datasetCacheKeyForRemove.add(datasetCacheKey); 76 | } 77 | } 78 | 79 | for (DatasetCacheKey datasetCacheKey : datasetCacheKeyForRemove) { 80 | cache.remove(datasetCacheKey); 81 | } 82 | 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /examples/isolines/isolines.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AcidMaps Demo - Isolines 5 | 12 | 13 | 87 | 88 | 89 |
90 | 91 | 92 | -------------------------------------------------------------------------------- /ams/src/acid_maps.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file acid_maps.cc 3 | * @brief 4 | * 5 | * @date 2010-11-02 6 | * @authors Fabio R. Panettieri 7 | * 8 | * @todo Brief and description 9 | */ 10 | 11 | #include "constants/constants.h" 12 | #include "core/configuration.h" 13 | #include "core/pixel.h" 14 | #include "core/validator.h" 15 | #include "simplify/simplifier.h" 16 | #include "simplify/simplifier_factory.h" 17 | #include "transform/transformer.h" 18 | #include "interpolate/interpolation.h" 19 | #include "interpolate/interpolation_factory.h" 20 | #include "render/renderer.h" 21 | #include "render/renderer_factory.h" 22 | #include "encode/encoder.h" 23 | #include "encode/encoder_factory.h" 24 | #include "./acid_maps.h" 25 | 26 | namespace acid_maps { 27 | 28 | int generate(Configuration* configuration, unsigned char** output_buffer, unsigned int* output_size) { 29 | Validator validator; 30 | int error = validator.validate(configuration); 31 | if(error) return error; 32 | 33 | if (configuration->dataset_size < configuration->simplify_size) { 34 | configuration->simplify_size = configuration->dataset_size; 35 | } 36 | 37 | Point* simplified_dataset = new Point[configuration->simplify_size]; 38 | Simplifier* simplifier = SimplifierFactory::get(configuration->simplify_method); 39 | simplifier->simplify(configuration->dataset, configuration->dataset_size, 40 | simplified_dataset, configuration->simplify_size); 41 | delete simplifier; 42 | 43 | Pixel* transformed_dataset = new Pixel[configuration->simplify_size]; 44 | Transformer* transformer = new Transformer(); 45 | transformer->transform(configuration->bounds, configuration->tile_size, 46 | simplified_dataset, configuration->simplify_size, transformed_dataset); 47 | delete transformer; 48 | delete[] simplified_dataset; 49 | 50 | int buffer_size = configuration->tile_size->width * configuration->tile_size->height; 51 | float* interpolated_bitmap = new float[buffer_size]; 52 | Interpolation* interpolation = InterpolationFactory::get(configuration->interpolation_strategy); 53 | interpolation->interpolate(configuration->tile_size, transformed_dataset, configuration->simplify_size, 54 | configuration->radius, interpolated_bitmap); 55 | delete interpolation; 56 | delete[] transformed_dataset; 57 | 58 | unsigned char* rgba_buffer = new unsigned char[buffer_size * RGBA]; 59 | Renderer* renderer = RendererFactory::get(configuration->renderer_type); 60 | renderer->render(interpolated_bitmap, configuration->tile_size, configuration->intervals, 61 | configuration->intervals_size, configuration->intervals_colors, rgba_buffer); 62 | delete renderer; 63 | delete[] interpolated_bitmap; 64 | 65 | Encoder* encoder = EncoderFactory::get(configuration->format); 66 | encoder->encode(configuration->tile_size, rgba_buffer, output_buffer, output_size); 67 | delete encoder; 68 | delete[] rgba_buffer; 69 | 70 | return 0; 71 | } 72 | 73 | }; // namespace acid_maps 74 | 75 | -------------------------------------------------------------------------------- /ams/test/simplify/grid_simplifier_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../../src/constants/constants.h" 3 | #include "../../src/core/point.h" 4 | #include "../../src/simplify/simplifier.h" 5 | #include "../../src/simplify/grid_simplifier.h" 6 | 7 | class GridSimplifierTest : public CppUnit::TestFixture { 8 | CPPUNIT_TEST_SUITE(GridSimplifierTest); 9 | CPPUNIT_TEST( singlePointDataset ); 10 | CPPUNIT_TEST( multiPointDataset ); 11 | CPPUNIT_TEST( emptyDataset ); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp() { 16 | dataset = create_dataset(); 17 | simplifier = new acid_maps::GridSimplifier(); 18 | } 19 | 20 | void tearDown() { 21 | delete simplifier; 22 | delete[] dataset; 23 | } 24 | 25 | void singlePointDataset () { 26 | simplify_size = 1; 27 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 28 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 29 | 30 | CPPUNIT_ASSERT_EQUAL(0.0f, simplified_dataset[0].x); 31 | CPPUNIT_ASSERT_EQUAL(0.0f, simplified_dataset[0].y); 32 | CPPUNIT_ASSERT_EQUAL(152.5f, simplified_dataset[0].value); 33 | 34 | delete[] simplified_dataset; 35 | } 36 | 37 | void multiPointDataset () { 38 | simplify_size = 4; 39 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 40 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 41 | 42 | for (int i = 0 ; i < 4; i++) { 43 | for (int j = 0 ; j < 4; j++) { 44 | if(dataset[j].x == simplified_dataset[i].x && dataset[j].y == simplified_dataset[i].y){ 45 | CPPUNIT_ASSERT_EQUAL(dataset[j].value, simplified_dataset[i].value); 46 | } 47 | } 48 | } 49 | 50 | delete[] simplified_dataset; 51 | } 52 | 53 | void emptyDataset () { 54 | simplify_size = 0; 55 | acid_maps::Point* simplified_dataset; 56 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 57 | } 58 | 59 | private: 60 | acid_maps::Simplifier* simplifier; 61 | acid_maps::Point* dataset; 62 | int dataset_size; 63 | int simplify_size; 64 | 65 | acid_maps::Point* create_dataset() { 66 | dataset_size = 4; 67 | 68 | acid_maps::Point* dataset = new acid_maps::Point[dataset_size]; 69 | acid_maps::Point* point; 70 | 71 | point = dataset; 72 | point->x = 90.0; 73 | point->y = 45.0; 74 | point->value = 200; 75 | 76 | point = dataset + 1; 77 | point->x = -90.0; 78 | point->y = 45.0; 79 | point->value = 100; 80 | 81 | point = dataset + 2; 82 | point->x = 90.0; 83 | point->y = -45.0; 84 | point->value = 50; 85 | 86 | point = dataset + 3; 87 | point->x = -90.0; 88 | point->y = -45.0; 89 | point->value = 260; 90 | return dataset; 91 | } 92 | 93 | }; 94 | 95 | CPPUNIT_TEST_SUITE_REGISTRATION( GridSimplifierTest ); 96 | -------------------------------------------------------------------------------- /geoserver/plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 4.0.0 6 | 7 | 8 | 9 | org.geoserver 10 | geoserver 11 | 2.2-SNAPSHOT 12 | 13 | 14 | 15 | 16 | org.geoserver 17 | wms 18 | 2.2-SNAPSHOT 19 | 20 | 21 | org.geoserver 22 | main 23 | 24 | 25 | org.geotools 26 | gt-render 27 | 28 | 29 | org.geotools 30 | gt-svg 31 | 32 | 33 | com.h2database 34 | h2 35 | 36 | 37 | org.geoserver 38 | main 39 | tests 40 | test 41 | 42 | 43 | xmlunit 44 | xmlunit 45 | test 46 | 47 | 48 | 49 | 50 | 51 | 52 | src/test/resources 53 | 54 | 55 | 56 | 57 | org.codehaus.mojo 58 | cobertura-maven-plugin 59 | 60 | 61 | 64 | 65 | **/*Exception.class 66 | 67 | 70 | 71 | 72 | 73 | 74 | 75 | org.geoserver 76 | acidmaps 77 | jar 78 | 1.0 79 | Acid Map Service Module 80 | 81 | 82 | 83 | codehaus 84 | codehaus 85 | http://repository.codehaus.org/ 86 | 87 | 88 | refractions 89 | refractions 90 | http://lists.refractions.net/m2 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /ams/test/render/sparse_renderer_intervals_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "../../src/render/sparse_renderer.h" 6 | 7 | class SparseRendererIntervalsTest : public CppUnit::TestFixture { 8 | CPPUNIT_TEST_SUITE(SparseRendererIntervalsTest); 9 | CPPUNIT_TEST( firstInterval ); 10 | CPPUNIT_TEST( evenInterval ); 11 | CPPUNIT_TEST( oddInterval ); 12 | CPPUNIT_TEST( firstValueInterval ); 13 | CPPUNIT_TEST( lastValueInterval ); 14 | CPPUNIT_TEST( firstValue ); 15 | CPPUNIT_TEST( lastValue ); 16 | CPPUNIT_TEST( randomIntervals ); 17 | CPPUNIT_TEST( outOfBoundsFirstInterval ); 18 | CPPUNIT_TEST( outOfBoundsLastInterval ); 19 | CPPUNIT_TEST_SUITE_END(); 20 | 21 | public: 22 | void setUp() { 23 | std::srand((unsigned)std::time(0)); 24 | 25 | renderer = new acid_maps::SparseRenderer(); 26 | intervals_size = std::rand() % 10 + 5; 27 | intervals = new float[intervals_size]; 28 | for (int i = 0; i < intervals_size; i++) { 29 | intervals[i] = (i + 1) * 10; 30 | } 31 | } 32 | 33 | void tearDown() { 34 | delete renderer; 35 | delete[] intervals; 36 | } 37 | 38 | void firstInterval () { 39 | CPPUNIT_ASSERT_EQUAL(0, renderer->interval(9, intervals, intervals_size)); 40 | } 41 | 42 | void evenInterval () { 43 | CPPUNIT_ASSERT_EQUAL(2, renderer->interval(24, intervals, intervals_size)); 44 | } 45 | 46 | void oddInterval () { 47 | CPPUNIT_ASSERT_EQUAL(3, renderer->interval(35, intervals, intervals_size)); 48 | } 49 | 50 | void firstValueInterval () { 51 | CPPUNIT_ASSERT_EQUAL(3, renderer->interval(31, intervals, intervals_size)); 52 | } 53 | 54 | void lastValueInterval () { 55 | CPPUNIT_ASSERT_EQUAL(4, renderer->interval(50, intervals, intervals_size)); 56 | } 57 | 58 | void firstValue () { 59 | CPPUNIT_ASSERT_EQUAL(0, renderer->interval(0, intervals, intervals_size)); 60 | } 61 | 62 | void lastValue () { 63 | CPPUNIT_ASSERT_EQUAL(intervals_size - 1, renderer->interval(intervals_size * 10, intervals, intervals_size)); 64 | } 65 | 66 | void randomIntervals () { 67 | float value; 68 | int interval; 69 | int validations = std::rand() % 80 + 20; 70 | for (int i = 0; i < validations; i++) { 71 | value = std::rand() % (intervals_size * 10) - 20; 72 | interval = value <= 0 ? 0 : (int)((value - 1) / 10); 73 | CPPUNIT_ASSERT_EQUAL(interval, renderer->interval(value, intervals, intervals_size)); 74 | } 75 | } 76 | 77 | void outOfBoundsFirstInterval () { 78 | CPPUNIT_ASSERT_EQUAL(0, renderer->interval(-4, intervals, intervals_size)); 79 | } 80 | 81 | void outOfBoundsLastInterval () { 82 | CPPUNIT_ASSERT_EQUAL(intervals_size - 1, renderer->interval(intervals_size * 11 , intervals, intervals_size)); 83 | } 84 | 85 | private: 86 | acid_maps::Renderer* renderer; 87 | float* intervals; 88 | int intervals_size; 89 | }; 90 | 91 | CPPUNIT_TEST_SUITE_REGISTRATION( SparseRendererIntervalsTest ); 92 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | AcidMaps 2 | 3 | SYNOPSIS 4 | 5 | AcidMaps is an open source library that generates interpolated images from a 6 | set of valued points in real time. 7 | 8 | It's can be used to generate advanced visualizations with point datasets: 9 | (e.g.: sales, temperature, atmospheric pressure, population) 10 | 11 | 12 | USAGE 13 | 14 | AcidMaps is compiled as a shared library. 15 | You can use it from C/C++ programs, Python (through CTypes), Java (through 16 | JNI), and any other system that can access a native library. 17 | 18 | Also in the downloads page you can find some pre-compiled AcidMaps packages 19 | which should cover common uses. We'll see how to use it with GeoServer (>= 2.1) in the 20 | following quick start. 21 | 22 | 23 | QUICK START 24 | 25 | The GeoServer plugin of AcidMaps allows you to use existent layers 26 | to generate interpolated maps. 27 | 28 | (NOTE: This plugin relies on functionality added on GeoServer 2.1, 29 | previous versions are not supported) 30 | 31 | 1. Download JNI adapter (http://goo.gl/HwJQ4) and extract to your system library path. 32 | (e.g.: /usr/lib/libacidmaps-jni.so) 33 | 34 | 2. Download GeoServer plugin (http://goo.gl/0qb7a) and extract to Geoserver lib directory. 35 | (e.g.: geoserver/WEB-INF/lib/acidmaps-2.0.jar) 36 | 37 | 3. Start GeoServer and try this 38 | http://localhost:8080/geoserver/wms?service=AMS&version=1.1.0&request=GetMap&layers=sf:bugsites&styles=&bbox=590223.4382724703,4914107.882513998,608462.4604629107,4920523.89081033&width=938&height=330&srs=EPSG:26713&format=image/png&VALUE_COLUMN=cat&SIMPLIFY_METHOD=3&SIMPLIFY_SIZE=90&INTERVALS[]=10,20,45,70,100&INTERVALS_COLORS[]=0xffffff80,0xff000080,0xffff0080,0x00ff0080,0x0000ff80&RENDERER_TYPE=2&INTERPOLATION_STRATEGY=2&radius=40 39 | 40 | 4. Opaaaa! 41 | 42 | Now, you can use any WMS layer in GeoServer whose geographic data is a point 43 | and has a Numeric column to be interpolated. 44 | 45 | You only need to add some parameters to WMS request and GeoServer will return 46 | an AMS interpolated map. 47 | 48 | An example of AMS request with OpenLayers: 49 | 50 | wms = new OpenLayers.Layer.WMS( 51 | "sf:bugsites - Untiled", "http://ams.xoomcode.com/geoserver/wms", 52 | { 53 | LAYERS: 'sf:bugsites', 54 | STYLES: '', 55 | format: format, 56 | VALUE_COLUMN:"cat", 57 | SIMPLIFY_METHOD: 3, 58 | SIMPLIFY_SIZE:90, 59 | 'INTERVALS[]':"10,20,45,70,100", 60 | 'INTERVALS_COLORS[]':"0xffffffcc,0xff0000cc,0xffff00cc,0xff00cc,0xffcc", 61 | RENDERER_TYPE:2, 62 | INTERPOLATION_STRATEGY:2, 63 | RADIUS:40, 64 | SERVICE:"AMS" 65 | }, 66 | {singleTile: true, ratio: 1} 67 | ); 68 | 69 | More information: https://github.com/XoomCode/AcidMaps/wiki 70 | 71 | 72 | LICENSE 73 | 74 | AcidMaps is released under LGPL. 75 | Copyright © 2011, XoomCode. All rights reserved. 76 | 77 | 78 | BUGS 79 | 80 | If you find a bug, please report it at 81 | http://github.com/XoomCode/AcidMaps/issues 82 | 83 | -------------------------------------------------------------------------------- /ams/test/simplify/copy_simplifier_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../../src/constants/constants.h" 3 | #include "../../src/core/point.h" 4 | #include "../../src/simplify/simplifier.h" 5 | #include "../../src/simplify/copy_simplifier.h" 6 | 7 | class CopySimplifierTest : public CppUnit::TestFixture { 8 | CPPUNIT_TEST_SUITE(CopySimplifierTest); 9 | CPPUNIT_TEST( singlePointDataset ); 10 | CPPUNIT_TEST( multiPointDataset ); 11 | CPPUNIT_TEST( emptyDataset ); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp() { 16 | dataset = create_dataset(); 17 | simplifier = new acid_maps::CopySimplifier(); 18 | } 19 | 20 | void tearDown() { 21 | delete simplifier; 22 | delete[] dataset; 23 | } 24 | 25 | void singlePointDataset () { 26 | simplify_size = 1; 27 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 28 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 29 | 30 | CPPUNIT_ASSERT_EQUAL(dataset[0].x, simplified_dataset[0].x); 31 | CPPUNIT_ASSERT_EQUAL(dataset[0].y, simplified_dataset[0].y); 32 | CPPUNIT_ASSERT_EQUAL(dataset[0].value, simplified_dataset[0].value); 33 | 34 | delete[] simplified_dataset; 35 | } 36 | 37 | void multiPointDataset () { 38 | simplify_size = 2; 39 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 40 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 41 | 42 | CPPUNIT_ASSERT_EQUAL(dataset[0].x, simplified_dataset[0].x); 43 | CPPUNIT_ASSERT_EQUAL(dataset[0].y, simplified_dataset[0].y); 44 | CPPUNIT_ASSERT_EQUAL(dataset[0].value, simplified_dataset[0].value); 45 | 46 | CPPUNIT_ASSERT_EQUAL(dataset[1].x, simplified_dataset[1].x); 47 | CPPUNIT_ASSERT_EQUAL(dataset[1].y, simplified_dataset[1].y); 48 | CPPUNIT_ASSERT_EQUAL(dataset[1].value, simplified_dataset[1].value); 49 | 50 | delete[] simplified_dataset; 51 | } 52 | 53 | void emptyDataset () { 54 | simplify_size = 0; 55 | acid_maps::Point* simplified_dataset; 56 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 57 | } 58 | 59 | private: 60 | acid_maps::Simplifier* simplifier; 61 | acid_maps::Point* dataset; 62 | int dataset_size; 63 | int simplify_size; 64 | 65 | acid_maps::Point* create_dataset() { 66 | dataset_size = 4; 67 | 68 | acid_maps::Point* dataset = new acid_maps::Point[dataset_size]; 69 | acid_maps::Point* point; 70 | 71 | point = dataset; 72 | point->x = 90.0; 73 | point->y = 45.0; 74 | point->value = 200; 75 | 76 | point = dataset + 1; 77 | point->x = -90.0; 78 | point->y = 45.0; 79 | point->value = 100; 80 | 81 | point = dataset + 2; 82 | point->x = 90.0; 83 | point->y = -45.0; 84 | point->value = 50; 85 | 86 | point = dataset + 3; 87 | point->x = -90.0; 88 | point->y = -45.0; 89 | point->value = 260; 90 | return dataset; 91 | } 92 | 93 | }; 94 | 95 | CPPUNIT_TEST_SUITE_REGISTRATION( CopySimplifierTest ); 96 | -------------------------------------------------------------------------------- /ams/test/simplify/sampling_simplifier_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../../src/constants/constants.h" 3 | #include "../../src/core/point.h" 4 | #include "../../src/simplify/simplifier.h" 5 | #include "../../src/simplify/sampling_simplifier.h" 6 | 7 | class SamplingSimplifierTest : public CppUnit::TestFixture { 8 | CPPUNIT_TEST_SUITE(SamplingSimplifierTest); 9 | CPPUNIT_TEST( singlePointDataset ); 10 | CPPUNIT_TEST( multiPointDataset ); 11 | CPPUNIT_TEST( emptyDataset ); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp() { 16 | dataset = create_dataset(); 17 | simplifier = new acid_maps::SamplingSimplifier(); 18 | } 19 | 20 | void tearDown() { 21 | delete simplifier; 22 | delete[] dataset; 23 | } 24 | 25 | void singlePointDataset () { 26 | simplify_size = 1; 27 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 28 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 29 | 30 | for (int i = 0 ; i < simplify_size; i++) { 31 | for (int j = 0 ; j < dataset_size; j++) { 32 | if(dataset[j].x == simplified_dataset[i].x && dataset[j].y == simplified_dataset[i].y){ 33 | CPPUNIT_ASSERT_EQUAL(dataset[j].value, simplified_dataset[i].value); 34 | } 35 | } 36 | } 37 | 38 | delete[] simplified_dataset; 39 | } 40 | 41 | void multiPointDataset () { 42 | simplify_size = 4; 43 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 44 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 45 | 46 | for (int i = 0 ; i < simplify_size; i++) { 47 | for (int j = 0 ; j < dataset_size; j++) { 48 | if(dataset[j].x == simplified_dataset[i].x && dataset[j].y == simplified_dataset[i].y){ 49 | CPPUNIT_ASSERT_EQUAL(dataset[j].value, simplified_dataset[i].value); 50 | } 51 | } 52 | } 53 | 54 | delete[] simplified_dataset; 55 | } 56 | 57 | void emptyDataset () { 58 | simplify_size = 0; 59 | acid_maps::Point* simplified_dataset; 60 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 61 | } 62 | 63 | private: 64 | acid_maps::Simplifier* simplifier; 65 | acid_maps::Point* dataset; 66 | int dataset_size; 67 | int simplify_size; 68 | 69 | acid_maps::Point* create_dataset() { 70 | dataset_size = 4; 71 | 72 | acid_maps::Point* dataset = new acid_maps::Point[dataset_size]; 73 | acid_maps::Point* point; 74 | 75 | point = dataset; 76 | point->x = 90.0; 77 | point->y = 45.0; 78 | point->value = 200; 79 | 80 | point = dataset + 1; 81 | point->x = -90.0; 82 | point->y = 45.0; 83 | point->value = 100; 84 | 85 | point = dataset + 2; 86 | point->x = 90.0; 87 | point->y = -45.0; 88 | point->value = 50; 89 | 90 | point = dataset + 3; 91 | point->x = -90.0; 92 | point->y = -45.0; 93 | point->value = 260; 94 | return dataset; 95 | } 96 | 97 | }; 98 | 99 | CPPUNIT_TEST_SUITE_REGISTRATION( SamplingSimplifierTest ); 100 | -------------------------------------------------------------------------------- /ams/src/simplify/grid_simplifier.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file grid_simplifier.cc 3 | * @brief Grid simplifier implementation 4 | * 5 | * @date 2011-01-12 6 | * @authors Fabio R. Panettieri 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "./grid_simplifier.h" 14 | #include "../constants/constants.h" 15 | #include "../core/point.h" 16 | 17 | namespace acid_maps { 18 | 19 | static const float MARGIN = 1.0001f; 20 | 21 | /** 22 | * TODO: SIMD 23 | */ 24 | void GridSimplifier::simplify(Point* dataset, int dataset_size, Point* simplified_dataset, int& simplify_size) { 25 | if (simplify_size == 0) return; 26 | 27 | // Step 1: Get the bounding box 28 | float min_x = (float)INT_MAX; 29 | float min_y = (float)INT_MAX; 30 | float max_x = INT_MIN; 31 | float max_y = INT_MIN; 32 | 33 | Point* point = NULL; 34 | for (int i = 0; i < dataset_size; i++) { 35 | point = dataset + i; 36 | if (point->x < min_x) min_x = point->x; 37 | if (point->x > max_x) max_x = point->x; 38 | if (point->y < min_y) min_y = point->y; 39 | if (point->y > max_y) max_y = point->y; 40 | } 41 | 42 | 43 | // Step 2: Create the NxN simplified grid 44 | // In order to create a NxN proportional grid that will allow us to simplify the dataset 45 | // we need to calculate the closest perfect square number to get N 46 | int cells = (int)std::floor(std::sqrt((float)simplify_size)); 47 | float cell_width = (max_x - min_x) * MARGIN / cells; 48 | float cell_height = (max_y - min_y) * MARGIN / cells; 49 | 50 | // Create the grid 51 | int grid_size = cells * cells; 52 | Point* grid = new Point[grid_size]; 53 | std::memset(grid, 0, grid_size * sizeof(grid[0])); 54 | 55 | // Create the grid counter 56 | int* cell_count = new int[grid_size]; 57 | std::memset(cell_count, 0, grid_size * sizeof(cell_count[0])); 58 | 59 | // Step 3: We iterate through the grid acummulating values 60 | int index_x, index_y, index; 61 | Point* cell; 62 | for (int i = 0; i < dataset_size; i++) { 63 | point = dataset + i; 64 | 65 | index_x = (int)((point->y - min_y) / cell_height); 66 | index_y = (int)((point->x - min_x) / cell_width); 67 | index = index_y * cells + index_x; 68 | 69 | cell = grid + index; 70 | cell->x += point->x; 71 | cell->y += point->y; 72 | cell->value += point->value; 73 | cell_count[index]++; 74 | } 75 | 76 | // Step 4: We calculate the average value for each cell 77 | // Also we check how many non empty cells exist 78 | simplify_size = 0; 79 | for (int i = 0; i < grid_size; i++) { 80 | if (cell_count[i] > 0) { 81 | grid[i].x /= cell_count[i]; 82 | grid[i].y /= cell_count[i]; 83 | 84 | // TODO: Make this configurable 85 | grid[i].value /= cell_count[i]; 86 | simplify_size++; 87 | } 88 | } 89 | 90 | // Step 5: Copy valued points only <= simplify_size 91 | index = 0; 92 | for (int i = 0; i < grid_size; i++) { 93 | if (cell_count[i] > 0) simplified_dataset[index++] = grid[i]; 94 | } 95 | 96 | delete[] grid; 97 | delete[] cell_count; 98 | } 99 | 100 | }; // namespace acid_maps 101 | 102 | -------------------------------------------------------------------------------- /ams/test/simplify/extremes_simplifier_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../../src/constants/constants.h" 3 | #include "../../src/core/point.h" 4 | #include "../../src/simplify/simplifier.h" 5 | #include "../../src/simplify/extremes_simplifier.h" 6 | 7 | class ExtremesSimplifierTest : public CppUnit::TestFixture { 8 | CPPUNIT_TEST_SUITE(ExtremesSimplifierTest); 9 | CPPUNIT_TEST( singlePointDataset ); 10 | CPPUNIT_TEST( multiPointDataset ); 11 | CPPUNIT_TEST( emptyDataset ); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp() { 16 | dataset = create_dataset(); 17 | simplifier = new acid_maps::ExtremesSimplifier(); 18 | } 19 | 20 | void tearDown() { 21 | delete simplifier; 22 | delete[] dataset; 23 | } 24 | 25 | void singlePointDataset () { 26 | simplify_size = 1; 27 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 28 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 29 | 30 | CPPUNIT_ASSERT_EQUAL(90.0f, simplified_dataset[0].x); 31 | CPPUNIT_ASSERT_EQUAL(-45.0f, simplified_dataset[0].y); 32 | CPPUNIT_ASSERT_EQUAL(50.0f, simplified_dataset[0].value); 33 | 34 | delete[] simplified_dataset; 35 | } 36 | 37 | void multiPointDataset () { 38 | simplify_size = 3; 39 | acid_maps::Point* simplified_dataset = new acid_maps::Point[simplify_size]; 40 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 41 | 42 | CPPUNIT_ASSERT_EQUAL(90.0f, simplified_dataset[0].x); 43 | CPPUNIT_ASSERT_EQUAL(-45.0f, simplified_dataset[0].y); 44 | CPPUNIT_ASSERT_EQUAL(50.0f, simplified_dataset[0].value); 45 | 46 | CPPUNIT_ASSERT_EQUAL(-90.0f, simplified_dataset[1].x); 47 | CPPUNIT_ASSERT_EQUAL(-45.0f, simplified_dataset[1].y); 48 | CPPUNIT_ASSERT_EQUAL(260.0f, simplified_dataset[1].value); 49 | 50 | CPPUNIT_ASSERT_EQUAL(-90.0f, simplified_dataset[2].x); 51 | CPPUNIT_ASSERT_EQUAL(45.0f, simplified_dataset[2].y); 52 | CPPUNIT_ASSERT_EQUAL(100.0f, simplified_dataset[2].value); 53 | 54 | delete[] simplified_dataset; 55 | } 56 | 57 | void emptyDataset () { 58 | simplify_size = 0; 59 | acid_maps::Point* simplified_dataset; 60 | simplifier->simplify(dataset, dataset_size, simplified_dataset, simplify_size); 61 | } 62 | 63 | private: 64 | acid_maps::Simplifier* simplifier; 65 | acid_maps::Point* dataset; 66 | int dataset_size; 67 | int simplify_size; 68 | 69 | acid_maps::Point* create_dataset() { 70 | dataset_size = 4; 71 | 72 | acid_maps::Point* dataset = new acid_maps::Point[dataset_size]; 73 | acid_maps::Point* point; 74 | 75 | point = dataset; 76 | point->x = 90.0; 77 | point->y = 45.0; 78 | point->value = 200; 79 | 80 | point = dataset + 1; 81 | point->x = -90.0; 82 | point->y = 45.0; 83 | point->value = 100; 84 | 85 | point = dataset + 2; 86 | point->x = 90.0; 87 | point->y = -45.0; 88 | point->value = 50; 89 | 90 | point = dataset + 3; 91 | point->x = -90.0; 92 | point->y = -45.0; 93 | point->value = 260; 94 | return dataset; 95 | } 96 | 97 | }; 98 | 99 | CPPUNIT_TEST_SUITE_REGISTRATION( ExtremesSimplifierTest ); 100 | -------------------------------------------------------------------------------- /ams/test/transform/transformer_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../../src/core/configuration.h" 3 | #include "../../src/core/bounds.h" 4 | #include "../../src/core/point.h" 5 | #include "../../src/core/pixel.h" 6 | #include "../../src/core/size.h" 7 | #include "../../src/transform/transformer.h" 8 | 9 | class TransformerTest : public CppUnit::TestFixture { 10 | CPPUNIT_TEST_SUITE(TransformerTest); 11 | CPPUNIT_TEST( singlePointDataset ); 12 | CPPUNIT_TEST( multiPointDataset ); 13 | CPPUNIT_TEST( emptyDataset ); 14 | CPPUNIT_TEST_SUITE_END(); 15 | 16 | public: 17 | void setUp() { 18 | configuration = new acid_maps::Configuration(); 19 | configuration->bounds = new acid_maps::Bounds(-180, -90, 180, 90); 20 | configuration->tile_size = new acid_maps::Size(512, 512); 21 | 22 | transformer = new acid_maps::Transformer(); 23 | } 24 | 25 | void tearDown() { 26 | delete configuration->tile_size; 27 | delete configuration->bounds; 28 | delete configuration; 29 | 30 | delete transformer; 31 | } 32 | 33 | void singlePointDataset () { 34 | acid_maps::Point* dataset = new acid_maps::Point[1]; 35 | dataset->x = 90.0; 36 | dataset->y = 45.0; 37 | dataset->value = 200; 38 | 39 | configuration->dataset_size = 1; 40 | configuration->dataset = dataset; 41 | 42 | acid_maps::Pixel* transformed_dataset = new acid_maps::Pixel[1]; 43 | transformer->transform(configuration->bounds, configuration->tile_size, dataset, 1, transformed_dataset); 44 | 45 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[0].x, configuration->tile_size->width / 4 * 3); 46 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[0].y, configuration->tile_size->height / 4); 47 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[0].value, dataset[0].value); 48 | 49 | delete[] transformed_dataset; 50 | delete[] dataset; 51 | } 52 | 53 | void multiPointDataset () { 54 | acid_maps::Point* dataset = new acid_maps::Point[4]; 55 | acid_maps::Point* point; 56 | 57 | point = dataset; 58 | point->x = 90.0; 59 | point->y = 45.0; 60 | point->value = 200; 61 | 62 | point = dataset + 1; 63 | point->x = -90.0; 64 | point->y = 45.0; 65 | point->value = 100; 66 | 67 | point = dataset + 2; 68 | point->x = 90.0; 69 | point->y = -45.0; 70 | point->value = 50; 71 | 72 | point = dataset + 3; 73 | point->x = -90.0; 74 | point->y = -45.0; 75 | point->value = 260; 76 | 77 | configuration->dataset_size = 4; 78 | configuration->dataset = dataset; 79 | 80 | acid_maps::Pixel* transformed_dataset = new acid_maps::Pixel[4]; 81 | transformer->transform(configuration->bounds, configuration->tile_size, dataset, 4, transformed_dataset); 82 | 83 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[0].x, configuration->tile_size->width / 4 * 3); 84 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[0].y, configuration->tile_size->height / 4); 85 | 86 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[1].x, configuration->tile_size->width / 4); 87 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[1].y, configuration->tile_size->height / 4); 88 | 89 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[2].x, configuration->tile_size->width / 4 * 3); 90 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[2].y, configuration->tile_size->height / 4 * 3); 91 | 92 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[3].x, configuration->tile_size->width / 4); 93 | CPPUNIT_ASSERT_EQUAL(transformed_dataset[3].y, configuration->tile_size->height / 4 * 3); 94 | 95 | delete[] transformed_dataset; 96 | delete[] dataset; 97 | } 98 | 99 | void emptyDataset () { 100 | acid_maps::Point* dataset = new acid_maps::Point[0]; 101 | 102 | configuration->dataset_size = 0; 103 | configuration->dataset = dataset; 104 | 105 | acid_maps::Pixel* transformed_dataset = new acid_maps::Pixel[0]; 106 | transformer->transform(configuration->bounds, configuration->tile_size, dataset, 0, transformed_dataset); 107 | 108 | delete[] transformed_dataset; 109 | delete[] dataset; 110 | } 111 | 112 | private: 113 | acid_maps::Configuration* configuration; 114 | acid_maps::Transformer* transformer; 115 | }; 116 | 117 | CPPUNIT_TEST_SUITE_REGISTRATION( TransformerTest ); 118 | -------------------------------------------------------------------------------- /ams/src/render/gradient_renderer.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * @file gradient_renderer.cc 3 | * 4 | * @date 2011-03-03 5 | * @authors Carlos J. Farina 6 | * Fabio R. Panettieri 7 | */ 8 | 9 | #include "./gradient_renderer.h" 10 | 11 | #include 12 | #include 13 | 14 | #include "../constants/constants.h" 15 | #include "../core/color.h" 16 | #include "../core/configuration.h" 17 | #include "../core/size.h" 18 | 19 | 20 | namespace acid_maps { 21 | 22 | /** 23 | * @todo Marching squares 24 | */ 25 | void GradientRenderer::render(float interpolated_bitmap[], Size* tile_size, float intervals[], 26 | int intervals_size, Color* intervals_colors, unsigned char* output_buffer) { 27 | 28 | // Size of the bitmap being interpolated 29 | int bitmap_size = tile_size->width * tile_size->height; 30 | 31 | // In order to generate smooth interpolations, a larger interpolated interval set is generated 32 | float* gradient = new float[GRADIENT_INTERVAL_SIZE]; 33 | 34 | // Interpolated colors 35 | Color* gradient_colors = new Color[GRADIENT_INTERVAL_SIZE]; 36 | 37 | // Color used to interpolate the smooth intervals 38 | Color* start_color, *end_color; 39 | Color* interpolated_color = new Color(); 40 | 41 | // Number of colors in the current range 42 | float color_steps; 43 | 44 | // Gradient offset acummulator. Used to store the offset between multiple interpolations 45 | unsigned int offset = 0; 46 | 47 | // Helper variables used to generate interpolated intervals 48 | float interval_step, interpolated_interval; 49 | 50 | // Helper variables used to split ranges proportionally 51 | float global_range = intervals[intervals_size - 1] - intervals[0]; 52 | float local_range; 53 | 54 | for (unsigned int i = 0; i < (intervals_size - 1); i++) { 55 | local_range = intervals[i + 1] - intervals[i]; 56 | color_steps = std::abs(GRADIENT_INTERVAL_SIZE * (local_range / global_range)); 57 | interval_step = (intervals[i + 1] - intervals[i]) / color_steps; 58 | 59 | start_color = intervals_colors + i; 60 | end_color = intervals_colors + i + 1; 61 | 62 | float coefficient = 0; 63 | for (int k = 0; k < color_steps; k++) { 64 | coefficient = k / color_steps; 65 | interpolated_interval = intervals[i] + interval_step * k; 66 | std::memcpy(gradient + offset + k, &interpolated_interval, sizeof(interpolated_interval)); 67 | 68 | interpolated_color->r = end_color->r * coefficient + start_color->r * (1 - coefficient); 69 | interpolated_color->g = end_color->g * coefficient + start_color->g * (1 - coefficient); 70 | interpolated_color->b = end_color->b * coefficient + start_color->b * (1 - coefficient); 71 | interpolated_color->a = end_color->a * coefficient + start_color->a * (1 - coefficient); 72 | 73 | std::memcpy(gradient_colors + offset + k, interpolated_color, sizeof(interpolated_color)); 74 | } 75 | offset += color_steps; 76 | } 77 | 78 | std::memcpy(gradient + GRADIENT_INTERVAL_SIZE - 1, intervals + intervals_size - 1, sizeof(intervals)); 79 | std::memcpy(gradient_colors + GRADIENT_INTERVAL_SIZE - 1, intervals_colors + intervals_size - 1, sizeof(intervals_colors)); 80 | 81 | int interval_index; 82 | for (unsigned int i = 0; i < bitmap_size; i++) { 83 | interval_index = this->interval(interpolated_bitmap[i], gradient, GRADIENT_INTERVAL_SIZE); 84 | std::memcpy(output_buffer + i * RGBA, gradient_colors + interval_index, sizeof(gradient_colors)); 85 | } 86 | 87 | delete interpolated_color; 88 | delete[] gradient; 89 | delete[] gradient_colors; 90 | } 91 | 92 | int GradientRenderer::interval(float value, float intervals[], int intervals_size) { 93 | int first = 0; 94 | int last = intervals_size - 1; 95 | int mid = 0; 96 | 97 | if (value < intervals[first]) { 98 | return first; 99 | } else if (value >= intervals[last]) { 100 | return last; 101 | } 102 | 103 | while (first <= last) { 104 | mid = (first + last) / 2; 105 | if (value > intervals[mid]) { 106 | first = mid + 1; 107 | } else if (value < intervals[mid]) { 108 | if (mid >= 1 && value > intervals[mid - 1]) { 109 | return mid; 110 | } else { 111 | last = mid - 1; 112 | } 113 | } else { 114 | return mid; 115 | } 116 | } 117 | 118 | // HACK: changed -1 to avoid segmentation faults. 119 | // This error should be made explicit 120 | return 0; 121 | } 122 | 123 | 124 | }; // namespace acid_maps 125 | 126 | -------------------------------------------------------------------------------- /flex/lib/src/com/xoomcode/acidmaps/AMSParameters.as: -------------------------------------------------------------------------------- 1 | package com.xoomcode.acidmaps 2 | { 3 | import com.xoomcode.acidmaps.interpolate.InterpolationStrategy; 4 | import com.xoomcode.acidmaps.renderer.RendererType; 5 | import com.xoomcode.acidmaps.simplify.SimplifyMethod; 6 | 7 | import org.openscales.core.layer.params.ogc.WMSParams; 8 | 9 | public class AMSParameters extends WMSParams 10 | { 11 | 12 | private var _valueColumn:String; 13 | 14 | private var _filter:String; 15 | 16 | private var _simplifyMethod:int = SimplifyMethod.COPY; 17 | 18 | private var _simplifySize:int = 64; 19 | 20 | private var _intervals:Array = new Array(); 21 | 22 | private var _intervalsColors:Array = new Array(); 23 | 24 | private var _rendererType:int = RendererType.SPARSE; 25 | 26 | private var _interpolationStrategy:int = InterpolationStrategy.LINEAR; 27 | 28 | private var _radius:int = 32; 29 | 30 | public function AMSParameters(layers:String, valueColumn:String) { 31 | super(layers); 32 | service = "AMS"; 33 | this.valueColumn = valueColumn; 34 | } 35 | 36 | public function set filter(value:String):void { 37 | _filter = value; 38 | } 39 | 40 | public function get filter():String { 41 | return _filter; 42 | } 43 | 44 | public function set valueColumn(value:String):void { 45 | _valueColumn = value; 46 | } 47 | 48 | public function get valueColumn():String { 49 | return _valueColumn; 50 | } 51 | 52 | public function set simplifyMethod(value:int):void { 53 | _simplifyMethod = value; 54 | } 55 | 56 | public function get simplifyMethod():int { 57 | return _simplifyMethod; 58 | } 59 | 60 | public function set simplifySize(value:int):void { 61 | _simplifySize = value; 62 | } 63 | 64 | public function get simplifySize():int { 65 | return _simplifySize; 66 | } 67 | 68 | public function set intervals(value:Array):void { 69 | _intervals = value; 70 | } 71 | 72 | public function get intervals():Array { 73 | return _intervals; 74 | } 75 | 76 | public function set intervalsColors(value:Array):void { 77 | _intervalsColors = value; 78 | } 79 | 80 | public function get intervalsColors():Array { 81 | return _intervalsColors; 82 | } 83 | 84 | public function set rendererType(value:int):void { 85 | _rendererType = value; 86 | } 87 | 88 | public function get rendererType():int { 89 | return _rendererType; 90 | } 91 | 92 | public function set interpolationStrategy(value:int):void { 93 | _interpolationStrategy = value; 94 | } 95 | 96 | public function get interpolationStrategy():int { 97 | return _interpolationStrategy; 98 | } 99 | 100 | public function set radius(value:int):void { 101 | _radius = value; 102 | } 103 | 104 | public function get radius():int { 105 | return _radius; 106 | } 107 | 108 | override public function toGETString():String { 109 | var str:String = super.toGETString(); 110 | 111 | if (_filter != null){ 112 | str +="&CQL_FILTER=(" + _filter + ")"; 113 | } 114 | 115 | if (_valueColumn != null){ 116 | str +="&VALUE_COLUMN=" + _valueColumn; 117 | } 118 | 119 | str += "&SIMPLIFY_METHOD=" + _simplifyMethod; 120 | 121 | str += "&SIMPLIFY_SIZE=" + _simplifySize; 122 | 123 | if(intervals != null && intervals.length > 0){ 124 | str += "&INTERVALS[]=" + buildIntervalsString(); 125 | } 126 | 127 | if(intervalsColors != null && intervalsColors.length > 0){ 128 | str += "&INTERVALS_COLORS[]=" + buildIntervalsColorsString(); 129 | } 130 | 131 | str += "&RENDERER_TYPE=" + _rendererType; 132 | 133 | str += "&INTERPOLATION_STRATEGY=" + _interpolationStrategy; 134 | 135 | str += "&RADIUS=" + _radius; 136 | 137 | return str; 138 | } 139 | 140 | private function buildIntervalsColorsString():String { 141 | var hexaIntervalsColors:Array = new Array(); 142 | for each(var value:uint in intervalsColors){ 143 | hexaIntervalsColors.push("0x" + value.toString(16)); 144 | } 145 | return buildArrayString(hexaIntervalsColors); 146 | } 147 | 148 | private function buildIntervalsString():String { 149 | return buildArrayString(intervals); 150 | } 151 | 152 | private function buildArrayString(arr:Array):String { 153 | var arrayStr:String = ""; 154 | 155 | for each(var value:Object in arr){ 156 | if(arrayStr == ""){ 157 | arrayStr += value; 158 | } else { 159 | arrayStr += "," + value; 160 | } 161 | } 162 | 163 | return arrayStr; 164 | } 165 | 166 | } 167 | } -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/bin-debug/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 44 | 45 | 46 | 47 | 101 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/bin-debug/AcidMapFlexClient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 44 | 45 | 46 | 47 | 101 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/html-template/index.template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | ${title} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 44 | 45 | 46 | 47 | 101 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /ams/test/interpolations_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../src/core/configuration.h" 3 | #include "../src/core/color.h" 4 | #include "../src/constants/constants.h" 5 | #include "../src/simplify/simplify_method.h" 6 | #include "../src/interpolate/interpolation_strategy.h" 7 | #include "../src/render/renderer_type.h" 8 | #include "../src/encode/encoding_format.h" 9 | #include "../src/acid_maps.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace ams = acid_maps; 16 | 17 | #define DATASET_SIZE 100 18 | #define SIMPLIFY_SIZE 75 19 | 20 | class InterpolationsTest : public CppUnit::TestFixture { 21 | CPPUNIT_TEST_SUITE(InterpolationsTest); 22 | CPPUNIT_TEST(dummyInterpolation); 23 | CPPUNIT_TEST(linearInterpolation); 24 | CPPUNIT_TEST(nearestNeighborInterpolation); 25 | CPPUNIT_TEST(inverseDistanceWeightingInterpolation); 26 | CPPUNIT_TEST_SUITE_END(); 27 | 28 | public: 29 | void setUp() { 30 | srand(time(NULL)); 31 | configuration = new ams::Configuration(); 32 | configuration->dataset = create_dataset(); 33 | configuration->dataset_size = DATASET_SIZE; 34 | configuration->simplify_size = SIMPLIFY_SIZE; 35 | configuration->simplify_method = ams::COPY; 36 | configuration->bounds = new ams::Bounds(-180, -90, 180, 90); 37 | configuration->tile_size = new ams::Size(1024, 512); 38 | configuration->intervals_size = 5; 39 | configuration->intervals = create_intervals(configuration->intervals_size); 40 | configuration->intervals_colors = create_intervals_colors(); 41 | configuration->renderer_type = ams::GRADIENT; 42 | 43 | configuration->format = ams::PNG; 44 | } 45 | 46 | void dummyInterpolation () { 47 | configuration->interpolation_strategy = ams::DUMMY; 48 | configuration->radius = 32; 49 | ams::generate(configuration, &output_buffer, &output_size); 50 | file = std::fopen("dummy.png", "wb"); 51 | } 52 | 53 | void linearInterpolation () { 54 | configuration->interpolation_strategy = ams::LINEAR; 55 | configuration->radius = 64; 56 | ams::generate(configuration, &output_buffer, &output_size); 57 | file = std::fopen("linear.png", "wb"); 58 | } 59 | 60 | void nearestNeighborInterpolation () { 61 | configuration->interpolation_strategy = ams::NEAREST_NEIGHBOR; 62 | ams::generate(configuration, &output_buffer, &output_size); 63 | file = std::fopen("nearest.png", "wb"); 64 | } 65 | 66 | void inverseDistanceWeightingInterpolation () { 67 | configuration->interpolation_strategy = ams::INVERSE_DISTANCE_WEIGHTING; 68 | ams::generate(configuration, &output_buffer, &output_size); 69 | file = std::fopen("idw.png", "wb"); 70 | } 71 | 72 | void tearDown() { 73 | std::fwrite(output_buffer, sizeof(unsigned char), output_size, file); 74 | std::fclose(file); 75 | free(output_buffer); 76 | delete[] configuration->intervals_colors; 77 | delete[] configuration->intervals; 78 | delete configuration->tile_size; 79 | delete configuration->bounds; 80 | delete[] configuration->dataset; 81 | delete configuration; 82 | } 83 | 84 | private: 85 | ams::Configuration* configuration; 86 | unsigned char* output_buffer; 87 | unsigned int output_size; 88 | std::FILE* file; 89 | 90 | ams::Point* create_dataset() { 91 | ams::Point* dataset = new ams::Point[DATASET_SIZE]; 92 | ams::Point* point; 93 | for (int i = 0; i < DATASET_SIZE; i++) { 94 | point = dataset + i; 95 | point->x = std::rand() % 360 - 180; 96 | point->y = std::rand() % 180 - 90; 97 | point->value = std::rand() % 100; 98 | } 99 | return dataset; 100 | } 101 | 102 | float* create_intervals(int intervals_size) { 103 | float* intervals = new float[intervals_size]; 104 | std::memset(intervals, 0, intervals_size * sizeof(intervals)); 105 | 106 | for (int i = 0; i < intervals_size; i++) { 107 | intervals[i] = (i + 1 ) * 20; 108 | } 109 | return intervals; 110 | } 111 | 112 | ams::Color* create_intervals_colors() { 113 | ams::Color* color; 114 | ams::Color* colors = new ams::Color[5]; 115 | 116 | color = colors; 117 | color->r = 0x20; color->g = 0x20; color->b = 0x20; color->a = 0xFF; 118 | 119 | color = colors + 1; 120 | color->r = 0xFF; color->g = 0x00; color->b = 0x00; color->a = 0xFF; 121 | 122 | color = colors + 2; 123 | color->r = 0xFF; color->g = 0xFF; color->b = 0x00; color->a = 0xFF; 124 | 125 | color = colors + 3; 126 | color->r = 0x00; color->g = 0xFF; color->b = 0x00; color->a = 0xFF; 127 | 128 | color = colors + 4; 129 | color->r = 0x00; color->g = 0x00; color->b = 0xFF; color->a = 0xFF; 130 | return colors; 131 | } 132 | }; 133 | 134 | CPPUNIT_TEST_SUITE_REGISTRATION( InterpolationsTest ); 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /ams/jni/JCAdapter.cc: -------------------------------------------------------------------------------- 1 | #include "JCAdapter.h" /* Auto-generated header created by javah -jni */ 2 | 3 | #include /* Java Native Interface headers */ 4 | #include /* Java Native Interface headers */ 5 | #include 6 | #include /* Include math.h for the prototype of function y0 */ 7 | 8 | #include "../src/core/configuration.h" 9 | #include "../src/core/size.h" 10 | #include "../src/core/color.h" 11 | #include "../src/acid_maps.h" 12 | #include "../src/render/renderer_type.h" 13 | #include "../src/constants/constants.h" 14 | 15 | namespace ams = acid_maps; 16 | 17 | int getArrayLength(JNIEnv* env, jclass configurationClass, jobject jconfiguration, jfieldID fieldId) { 18 | jarray field = (jarray)env->GetObjectField(jconfiguration, fieldId); 19 | int length = 0; 20 | if(field) length = env->GetArrayLength(field); 21 | return length; 22 | } 23 | 24 | int getFloatArrayLength(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 25 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[F"); 26 | return getArrayLength(env, configurationClass, jconfiguration, fieldId); 27 | } 28 | 29 | int getCharArrayLength(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 30 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[B"); 31 | return getArrayLength(env, configurationClass, jconfiguration, fieldId); 32 | } 33 | 34 | int getIntArrayLength(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 35 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[I"); 36 | return getArrayLength(env, configurationClass, jconfiguration, fieldId); 37 | } 38 | 39 | int getIntField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 40 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "I"); 41 | return env->GetIntField(jconfiguration, fieldId); 42 | } 43 | 44 | char getByteField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 45 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "B"); 46 | return env->GetByteField(jconfiguration, fieldId); 47 | } 48 | 49 | float getFloatField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 50 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "F"); 51 | return env->GetFloatField(jconfiguration, fieldId); 52 | } 53 | 54 | float* getFloatArrayField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 55 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[F"); 56 | jfloatArray field = (jfloatArray)env->GetObjectField(jconfiguration, fieldId); 57 | 58 | float* floatArray = NULL; 59 | if(field) floatArray = env->GetFloatArrayElements(field, NULL); 60 | return floatArray; 61 | } 62 | 63 | jint* getIntArrayField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 64 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[I"); 65 | jintArray field = (jintArray)env->GetObjectField(jconfiguration, fieldId); 66 | 67 | jint* array = NULL; 68 | if(field) array = env->GetIntArrayElements(field, NULL); 69 | return array; 70 | } 71 | 72 | unsigned char* getCharArrayField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 73 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[B"); 74 | jbyteArray field = (jbyteArray)env->GetObjectField(jconfiguration, fieldId); 75 | 76 | unsigned char* array = NULL; 77 | if(field) array = (unsigned char*)env->GetByteArrayElements(field, NULL); 78 | return array; 79 | } 80 | 81 | ams::Point* getPointArrayField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id, int size) { 82 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[Lcom/xoomcode/acidmaps/core/Point;"); 83 | jobjectArray field = (jobjectArray)env->GetObjectField(jconfiguration, fieldId); 84 | jclass pointClass = env->FindClass("com/xoomcode/acidmaps/core/Point"); 85 | 86 | ams::Point* array = NULL; 87 | if(field){ 88 | array = new ams::Point[size]; 89 | ams::Point* point = new ams::Point(); 90 | for (int i = 0; i < size; ++i) { 91 | jobject jpoint = (jobject)env->GetObjectArrayElement(field, i); 92 | point->x = getFloatField(env, pointClass, jpoint, "x"); 93 | point->y = getFloatField(env, pointClass, jpoint, "y"); 94 | point->value = getFloatField(env, pointClass, jpoint, "value"); 95 | memcpy(array + i, point, sizeof(ams::Point)); 96 | } 97 | delete point; 98 | } 99 | return array; 100 | } 101 | 102 | ams::Color* getColorArrayField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id, int size) { 103 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "[Lcom/xoomcode/acidmaps/core/Color;"); 104 | jobjectArray field = (jobjectArray)env->GetObjectField(jconfiguration, fieldId); 105 | jclass colorClass = env->FindClass("com/xoomcode/acidmaps/core/Color"); 106 | 107 | ams::Color* colorArray = NULL; 108 | if(field){ 109 | colorArray = new ams::Color[size]; 110 | ams::Color* color; 111 | for (int i = 0; i < size; i++) { 112 | jobject jcolor = (jobject)env->GetObjectArrayElement(field, i); 113 | color = colorArray + i; 114 | color->r = getByteField(env, colorClass, jcolor, "r"); 115 | color->g = getByteField(env, colorClass, jcolor, "g"); 116 | color->b = getByteField(env, colorClass, jcolor, "b"); 117 | color->a = getByteField(env, colorClass, jcolor, "a"); 118 | } 119 | } 120 | return colorArray; 121 | } 122 | 123 | ams::Bounds* getBoundField(JNIEnv* env, jclass configurationClass, jobject jconfiguration, const char* id) { 124 | jclass boundClass = env->FindClass("com/xoomcode/acidmaps/core/Bounds"); 125 | jfieldID fieldId = env->GetFieldID(configurationClass, id, "Lcom/xoomcode/acidmaps/core/Bounds;"); 126 | jobject jbounds = (jobject)env->GetObjectField(jconfiguration, fieldId); 127 | 128 | ams::Bounds* bound = NULL; 129 | if(jbounds){ 130 | bound = new ams::Bounds(); 131 | bound->min_x = getFloatField(env, boundClass, jbounds, "minX"); 132 | bound->min_y = getFloatField(env, boundClass, jbounds, "minY"); 133 | bound->max_x = getFloatField(env, boundClass, jbounds, "maxX"); 134 | bound->max_y = getFloatField(env, boundClass, jbounds, "maxY"); 135 | } 136 | return bound; 137 | } 138 | 139 | void buildConfiguration(JNIEnv* env, jobject jconfiguration, ams::Configuration* configuration){ 140 | jclass configurationClass = env->FindClass("com/xoomcode/acidmaps/core/Configuration"); 141 | 142 | configuration->bounds = getBoundField(env, configurationClass, jconfiguration, "bounds"); 143 | configuration->dataset_size = getIntField(env, configurationClass, jconfiguration, "datasetSize"); 144 | configuration->dataset = getPointArrayField(env, configurationClass, jconfiguration, "dataset", configuration->dataset_size); 145 | 146 | configuration->simplify_method = getIntField(env, configurationClass, jconfiguration, "simplifyMethod"); 147 | configuration->simplify_size = getIntField(env, configurationClass, jconfiguration, "simplifySize"); 148 | configuration->interpolation_strategy = getIntField(env, configurationClass, jconfiguration, "interpolationStrategy"); 149 | 150 | int width = getIntField(env, configurationClass, jconfiguration, "width"); 151 | int height = getIntField(env, configurationClass, jconfiguration, "height"); 152 | configuration->tile_size = new ams::Size(width, height); 153 | 154 | configuration->intervals = getFloatArrayField(env, configurationClass, jconfiguration, "intervals"); 155 | configuration->intervals_size = getFloatArrayLength(env, configurationClass, jconfiguration, "intervals"); 156 | configuration->intervals_colors = getColorArrayField(env, configurationClass, jconfiguration, "intervalsColors", configuration->intervals_size); 157 | 158 | configuration->renderer_type = getIntField(env, configurationClass, jconfiguration, "rendererType"); 159 | configuration->radius = getIntField(env, configurationClass, jconfiguration, "radius"); 160 | configuration->format = getIntField(env, configurationClass, jconfiguration, "format"); 161 | } 162 | 163 | JNIEXPORT jobject JNICALL Java_com_xoomcode_acidmaps_adapter_JCAdapter_interpolateC 164 | (JNIEnv* env, jobject obj, jobject jconfiguration) 165 | { 166 | ams::Configuration* configuration = new ams::Configuration(); 167 | buildConfiguration(env, jconfiguration, configuration); 168 | 169 | unsigned char* charOut; 170 | unsigned int charOutSize; 171 | 172 | int error = ams::generate(configuration, &charOut, &charOutSize); 173 | 174 | jbyteArray out = NULL; 175 | 176 | if(error != 0){ 177 | jclass configurationClass = env->FindClass("com/xoomcode/acidmaps/core/Configuration"); 178 | jfieldID fieldId = env->GetFieldID(configurationClass, "error", "I"); 179 | env->SetIntField(jconfiguration, fieldId, error); 180 | } else { 181 | jbyte* joutpt = new jbyte[charOutSize]; 182 | memcpy(joutpt, charOut, charOutSize * sizeof(unsigned char)); 183 | out = env->NewByteArray(charOutSize); 184 | env->SetByteArrayRegion(out, 0, charOutSize, joutpt); 185 | free(charOut); 186 | delete[] joutpt; 187 | } 188 | 189 | delete[] configuration->dataset; 190 | delete configuration->bounds; 191 | delete configuration->tile_size; 192 | delete[] configuration->intervals_colors; 193 | delete configuration; 194 | 195 | return out; 196 | } 197 | 198 | -------------------------------------------------------------------------------- /flex/demo/AcidMapFlexClient/bin-debug/AC_OETags.js: -------------------------------------------------------------------------------- 1 | // Flash Player Version Detection - Rev 1.6 2 | // Detect Client Browser type 3 | // Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved. 4 | var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; 5 | var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; 6 | var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; 7 | 8 | function ControlVersion() 9 | { 10 | var version; 11 | var axo; 12 | var e; 13 | 14 | // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry 15 | 16 | try { 17 | // version will be set for 7.X or greater players 18 | axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); 19 | version = axo.GetVariable("$version"); 20 | } catch (e) { 21 | } 22 | 23 | if (!version) 24 | { 25 | try { 26 | // version will be set for 6.X players only 27 | axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); 28 | 29 | // installed player is some revision of 6.0 30 | // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, 31 | // so we have to be careful. 32 | 33 | // default to the first public version 34 | version = "WIN 6,0,21,0"; 35 | 36 | // throws if AllowScripAccess does not exist (introduced in 6.0r47) 37 | axo.AllowScriptAccess = "always"; 38 | 39 | // safe to call for 6.0r47 or greater 40 | version = axo.GetVariable("$version"); 41 | 42 | } catch (e) { 43 | } 44 | } 45 | 46 | if (!version) 47 | { 48 | try { 49 | // version will be set for 4.X or 5.X player 50 | axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); 51 | version = axo.GetVariable("$version"); 52 | } catch (e) { 53 | } 54 | } 55 | 56 | if (!version) 57 | { 58 | try { 59 | // version will be set for 3.X player 60 | axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); 61 | version = "WIN 3,0,18,0"; 62 | } catch (e) { 63 | } 64 | } 65 | 66 | if (!version) 67 | { 68 | try { 69 | // version will be set for 2.X player 70 | axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); 71 | version = "WIN 2,0,0,11"; 72 | } catch (e) { 73 | version = -1; 74 | } 75 | } 76 | 77 | return version; 78 | } 79 | 80 | // JavaScript helper required to detect Flash Player PlugIn version information 81 | function GetSwfVer(){ 82 | // NS/Opera version >= 3 check for Flash plugin in plugin array 83 | var flashVer = -1; 84 | 85 | if (navigator.plugins != null && navigator.plugins.length > 0) { 86 | if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { 87 | var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; 88 | var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; 89 | var descArray = flashDescription.split(" "); 90 | var tempArrayMajor = descArray[2].split("."); 91 | var versionMajor = tempArrayMajor[0]; 92 | var versionMinor = tempArrayMajor[1]; 93 | var versionRevision = descArray[3]; 94 | if (versionRevision == "") { 95 | versionRevision = descArray[4]; 96 | } 97 | if (versionRevision[0] == "d") { 98 | versionRevision = versionRevision.substring(1); 99 | } else if (versionRevision[0] == "r") { 100 | versionRevision = versionRevision.substring(1); 101 | if (versionRevision.indexOf("d") > 0) { 102 | versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); 103 | } 104 | } else if (versionRevision[0] == "b") { 105 | versionRevision = versionRevision.substring(1); 106 | } 107 | var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; 108 | } 109 | } 110 | // MSN/WebTV 2.6 supports Flash 4 111 | else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; 112 | // WebTV 2.5 supports Flash 3 113 | else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; 114 | // older WebTV supports Flash 2 115 | else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; 116 | else if ( isIE && isWin && !isOpera ) { 117 | flashVer = ControlVersion(); 118 | } 119 | return flashVer; 120 | } 121 | 122 | // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available 123 | function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 124 | { 125 | versionStr = GetSwfVer(); 126 | if (versionStr == -1 ) { 127 | return false; 128 | } else if (versionStr != 0) { 129 | if(isIE && isWin && !isOpera) { 130 | // Given "WIN 2,0,0,11" 131 | tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] 132 | tempString = tempArray[1]; // "2,0,0,11" 133 | versionArray = tempString.split(","); // ['2', '0', '0', '11'] 134 | } else { 135 | versionArray = versionStr.split("."); 136 | } 137 | var versionMajor = versionArray[0]; 138 | var versionMinor = versionArray[1]; 139 | var versionRevision = versionArray[2]; 140 | 141 | // is the major.revision >= requested major.revision AND the minor version >= requested minor 142 | if (versionMajor > parseFloat(reqMajorVer)) { 143 | return true; 144 | } else if (versionMajor == parseFloat(reqMajorVer)) { 145 | if (versionMinor > parseFloat(reqMinorVer)) 146 | return true; 147 | else if (versionMinor == parseFloat(reqMinorVer)) { 148 | if (versionRevision >= parseFloat(reqRevision)) 149 | return true; 150 | } 151 | } 152 | return false; 153 | } 154 | } 155 | 156 | function AC_AddExtension(src, ext) 157 | { 158 | var qIndex = src.indexOf('?'); 159 | if ( qIndex != -1) 160 | { 161 | // Add the extention (if needed) before the query params 162 | var path = src.substring(0, qIndex); 163 | if (path.length >= ext.length && path.lastIndexOf(ext) == (path.length - ext.length)) 164 | return src; 165 | else 166 | return src.replace(/\?/, ext+'?'); 167 | } 168 | else 169 | { 170 | // Add the extension (if needed) to the end of the URL 171 | if (src.length >= ext.length && src.lastIndexOf(ext) == (src.length - ext.length)) 172 | return src; // Already have extension 173 | else 174 | return src + ext; 175 | } 176 | } 177 | 178 | function AC_Generateobj(objAttrs, params, embedAttrs) 179 | { 180 | var str = ''; 181 | if (isIE && isWin && !isOpera) 182 | { 183 | str += ' '; 189 | str += ''; 190 | } else { 191 | str += '= 3 check for Flash plugin in plugin array 83 | var flashVer = -1; 84 | 85 | if (navigator.plugins != null && navigator.plugins.length > 0) { 86 | if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { 87 | var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; 88 | var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; 89 | var descArray = flashDescription.split(" "); 90 | var tempArrayMajor = descArray[2].split("."); 91 | var versionMajor = tempArrayMajor[0]; 92 | var versionMinor = tempArrayMajor[1]; 93 | var versionRevision = descArray[3]; 94 | if (versionRevision == "") { 95 | versionRevision = descArray[4]; 96 | } 97 | if (versionRevision[0] == "d") { 98 | versionRevision = versionRevision.substring(1); 99 | } else if (versionRevision[0] == "r") { 100 | versionRevision = versionRevision.substring(1); 101 | if (versionRevision.indexOf("d") > 0) { 102 | versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); 103 | } 104 | } else if (versionRevision[0] == "b") { 105 | versionRevision = versionRevision.substring(1); 106 | } 107 | var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; 108 | } 109 | } 110 | // MSN/WebTV 2.6 supports Flash 4 111 | else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; 112 | // WebTV 2.5 supports Flash 3 113 | else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; 114 | // older WebTV supports Flash 2 115 | else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; 116 | else if ( isIE && isWin && !isOpera ) { 117 | flashVer = ControlVersion(); 118 | } 119 | return flashVer; 120 | } 121 | 122 | // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available 123 | function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 124 | { 125 | versionStr = GetSwfVer(); 126 | if (versionStr == -1 ) { 127 | return false; 128 | } else if (versionStr != 0) { 129 | if(isIE && isWin && !isOpera) { 130 | // Given "WIN 2,0,0,11" 131 | tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] 132 | tempString = tempArray[1]; // "2,0,0,11" 133 | versionArray = tempString.split(","); // ['2', '0', '0', '11'] 134 | } else { 135 | versionArray = versionStr.split("."); 136 | } 137 | var versionMajor = versionArray[0]; 138 | var versionMinor = versionArray[1]; 139 | var versionRevision = versionArray[2]; 140 | 141 | // is the major.revision >= requested major.revision AND the minor version >= requested minor 142 | if (versionMajor > parseFloat(reqMajorVer)) { 143 | return true; 144 | } else if (versionMajor == parseFloat(reqMajorVer)) { 145 | if (versionMinor > parseFloat(reqMinorVer)) 146 | return true; 147 | else if (versionMinor == parseFloat(reqMinorVer)) { 148 | if (versionRevision >= parseFloat(reqRevision)) 149 | return true; 150 | } 151 | } 152 | return false; 153 | } 154 | } 155 | 156 | function AC_AddExtension(src, ext) 157 | { 158 | var qIndex = src.indexOf('?'); 159 | if ( qIndex != -1) 160 | { 161 | // Add the extention (if needed) before the query params 162 | var path = src.substring(0, qIndex); 163 | if (path.length >= ext.length && path.lastIndexOf(ext) == (path.length - ext.length)) 164 | return src; 165 | else 166 | return src.replace(/\?/, ext+'?'); 167 | } 168 | else 169 | { 170 | // Add the extension (if needed) to the end of the URL 171 | if (src.length >= ext.length && src.lastIndexOf(ext) == (src.length - ext.length)) 172 | return src; // Already have extension 173 | else 174 | return src + ext; 175 | } 176 | } 177 | 178 | function AC_Generateobj(objAttrs, params, embedAttrs) 179 | { 180 | var str = ''; 181 | if (isIE && isWin && !isOpera) 182 | { 183 | str += ' '; 189 | str += ''; 190 | } else { 191 | str += ' 2 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 94 | 95 | 96 | 97 | 98 | 340 | 341 | 342 | --------------------------------------------------------------------------------