themamap-0.41/0000755000175000017500000000000010637754774014364 5ustar dcorpatauxdcorpatauxthemamap-0.41/Color.php0000755000175000017500000002077510627247256016160 0ustar dcorpatauxdcorpatauxgetColorRgb(); return $colorCymk; } /** * @return int RGB hex color value */ public function getRgbHexString() { $colorRgb = $this->getColorRgb(); $hexString = sprintf("%02x",$colorRgb->getRedLevel()); $hexString .= sprintf("%02x",$colorRgb->getGreenLevel()); $hexString .= sprintf("%02x",$colorRgb->getBlueLevel()); return $hexString; } /** * @return bool True if colors are the same */ public function equals($color) { return $this->getColorRgb()->getRedLevel() == $color->getColorRgb()->getRedLevel() && $this->getColorRgb()->getGreenLevel() == $color->getColorRgb()->getGreenLevel() && $this->getColorRgb()->getBlueLevel() == $color->getColorRgb()->getBlueLevel(); } } /** * RGB Representation of color * @package Color */ class ColorRgb extends Color { /** * @var int level [0..255] */ protected $redLevel; protected $greenLevel; protected $blueLevel; public function __construct($red = 0, $green = 0, $blue = 0) { $this->redLevel = intval($red); $this->greenLevel = intval($green); $this->blueLevel = intval($blue); } public function getColorHsv() { $hue = 0.0; $saturation = 0.0; $value = 0.0; $red = $this->getRedLevel()/255.0; $blue = $this->getBlueLevel()/255.0; $green = $this->getGreenLevel()/255.0; $rgbMax = max($this->getRgbArray())/255.0; $rgbMin = min($this->getRgbArray())/255.0; if($rgbMax < (1/256.0)) { return new ColorHsv(0.0, 0.0, 0.0); } else { $saturation = ($rgbMax - $rgbMin)/$rgbMax; $value = $rgbMax; } if ($red == $rgbMax && !($blue == $rgbMax && $green == $rgbMax)) { $hue = ($green - $blue)/($rgbMax - $rgbMin); } else if ($green == $rgbMax && !($red == $rgbMax && $green == $rgbMax)) { $hue = 2 + ($blue - $red)/($rgbMax - $rgbMin); } else if (!($green == $rgbMax && $red == $rgbMax)) { $hue = 4 + ($red - $green)/($rgbMax - $rgbMin); } else { //Undefined } $hue *= 60; if ($hue < 0) {$hue += 360;} return new ColorHsv((float)$hue, (float)$saturation, (float)$value); } /** * @see Color::getColorRgb() */ public function getColorRgb() { return $this; } public function getRedLevel() { return $this->redLevel; } public function getGreenLevel() { return $this->greenLevel; } public function getBlueLevel() { return $this->blueLevel; } public function getRgbArray() { return array($this->redLevel, $this->greenLevel, $this->blueLevel); } static public function hex2rgbArray($rgbHexString) { if($rgbHexString{0} == '#') { $rgbHexString = substr($rgbHexString,1); } $rgbArray = array( intval(substr($rgbHexString,0,2),16), intval(substr($rgbHexString,2,2),16), intval(substr($rgbHexString,4,2),16) ); foreach ($rgbArray as $hexLevel) { if ($hexLevel < 0 || $hexLevel > 255 ) { throw new Exception("Invalid rgb hex color string: $rgbHexString"); } } return $rgbArray; } /** * Sets the color from a color hex string * @param string Hex color string (format: #rrggbb) */ public function setFromHex($rgbHexString) { $rgbArray = self::hex2rgbArray($rgbHexString); $this->redLevel = $rgbArray[0]; $this->greenLevel = $rgbArray[1]; $this->blueLevel = $rgbArray[2]; } } /** * HSV Representation of color * @package Color */ class ColorHsv extends Color { /** * @var float hue (0-360) */ protected $hueLevel; /** * @var float saturation (0-1) */ protected $saturationLevel; /** * @var float value (0-1) */ protected $valueLevel; public function __construct($hue, $saturation, $value) { $this->hueLevel = (float)$hue; $this->saturationLevel = (float)$saturation; $this->valueLevel = (float)$value; } /** * @see Color::getColorRgb() */ public function getColorRgb() { //Transformation parameters $f;$p;$q;$t; //There are 6 cases $case; $red;$green;$blue; $hue = $this->hueLevel; $saturation = $this->saturationLevel; $value = $this->valueLevel; if ($saturation == 0) { $red = $value; $green = $value; $blue = $value; } else { $hue == 360.0 ? 60.0 : $hue; $case = intval(floor($hue/60)) % 6; $f = $hue/60 - $case; $p = $value * (1 - $saturation); $q = $value * (1 - ($saturation * $f)); $t = $value * (1 - ($saturation * (1 - $f))); switch($case) { case 0: $red=$value; $green=$t; $blue=$p; break; case 1: $red=$q; $green=$value; $blue=$p; break; case 2: $red=$p; $green=$value; $blue=$t; break; case 3: $red=$p; $green=$q; $blue=$value; break; case 4: $red=$t; $green=$p; $blue=$value; break; case 5: $red=$value; $green=$p; $blue=$q; break; } } return new ColorRgb(intval($red*255),intval($green*255),intval($blue*255)); } /** * @see Color::$getColorHsv() */ public function getColorHsv() { return $this; } public function getHueLevel() { return $this->hueLevel; } public function getSaturationLevel() { return $this->saturationLevel; } public function getValueLevel() { return $this->valueLevel; } public function getHsvArray() { return array($this->hueLevel, $this->saturationLevel, $this->valueLevel); } } /** * HSV Representation of color * @package Color */ class ColorCymk extends Color { /** * @var int level [0..255] */ protected $cyanLevel; protected $yellowLevel; protected $magentaLevel; protected $blackLevel; public function getCyanLevel() { return $this->cyanLevel; } public function getYellowLevel() { return $this->yellowLevel; } public function getMagentaLevel() { return $this->magentaLevel; } public function getBlackLevel() { return $this->blackLevel; } /** * @see Color::getColorRgb() */ public function getColorRgb() { // TODO } public function getColorHsv() { // TODO } /** * @see Color::getColorCymk() */ public function getColorCymk() { return this; } } ?>themamap-0.41/Bin.php0000755000175000017500000000453110603177011015563 0ustar dcorpatauxdcorpatauxnbVal = $nbVal; $this->label = $label; $this->lowerBound = $lowerBound; $this->upperBound = $upperBound; $this->isLast = $isLast; } /** * @return int */ public function getNbVal() { return $this->nbVal; } /** * @return mixed */ public function getLowerBound() { return $this->lowerBound; } /** * @return mixed */ public function getUpperBound() { return $this->upperBound; } /** * @return bool */ public function isLastBin() { return $this->isLast; } /** * @return mixed */ public function getLabel() { return $this->label; } public function setLabel($name) { $this->label = $name; } } ?>themamap-0.41/COPYING0000644000175000017500000003503610603177011015376 0ustar dcorpatauxdcorpatauxThe GNU General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS themamap-0.41/doc/0000755000175000017500000000000010637754774015131 5ustar dcorpatauxdcorpatauxthemamap-0.41/doc/specs/0000755000175000017500000000000010637754774016246 5ustar dcorpatauxdcorpatauxthemamap-0.41/doc/specs/class.dia0000644000175000017500000031704210603177011020011 0ustar dcorpatauxdcorpataux #A4# ## #ThemaMap API# ## #GOWS# ## #Cartoweb geostatistical plugin# ## #Common# ## #Client# ## #Server# #Chart# ## ## #VerticalBlock# ## ## #Pie# ## ## #Bars# ## ## ## ## ## ## ## ## #Veritcal Block is not a predefined type of Charts within JPGraph and Artichow# ## #Data Management# #Classification# ## ## #classes[]# ## ## ## #getColorPalette# ## #ColorPalette# ## #_constructor# ## ## ## #distribution# #classes[]# ## ## #Distribution# ## ## #values[]# ## ## ## #min# ## ## ## #max# ## ## ## #mean# ## ## ## #stdDev# ## ## ## #count# #int# ## ## #classifyByEqIntervals# ## #Classification# ## #nbBins# #int# ## ## #classifyByNatBreaks# ## #Classification# ## #nbBins# #int# ## ## #classifyByQuantile# ## ## ## #nbBins# #int# ## ## #getMin# ## ## ## #getMax# ## ## ## #getMean# ## ## ## #getStdDev# ## ## ## #classifyWithContingencyTable# ## ## ## #classifyCustom# ## ## ## #classLimits[]# ## ## ## #We directly use API of Artichow or JPGraph to manage Pie and Bars. We define a new class Vertical Block which will inherit from the line class.# #Line# ## ## ## ## ## ## #ClientGeostat# ## ## #ServerGeostat# ## ## #CommonGeostat# ## ## #Bin# ## ## #min# ## ## ## #max# ## ## ## #nbValues# ## ## ## #label# ## ## ## #ColorPalette# ## ## #colors[]# #Color# ## ## #getColorForVal# ## ## ## #value# ## ## ## #getLegend# ## ## ## #getDiscreteLegend# ## ## ## #array# ## ## ## #ClassMethod may be : EqualInterval, Quantile, etc.# #ColorRamp method may be : HSV, Cie Lab, Lab LCh, etc. (http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=17221)# #Color# ## ## #red# ## ## ## #green# ## ## ## #blue# ## ## ## themamap-0.41/doc/apidoc-config.ini0000644000175000017500000001045710603177011020313 0ustar dcorpatauxdcorpataux;; phpDocumentor parse configuration file ;; ;; This file is designed to cut down on repetitive typing on the command-line or web interface ;; You can copy this file to create a number of configuration files that can be used with the ;; command-line switch -c, as in phpdoc -c default.ini or phpdoc -c myini.ini. The web ;; interface will automatically generate a list of .ini files that can be used. ;; ;; default.ini is used to generate the online manual at http://www.phpdoc.org/docs ;; ;; ALL .ini files must be in the user subdirectory of phpDocumentor with an extension of .ini ;; ;; Copyright 2002, Greg Beaver ;; ;; WARNING: do not change the name of any command-line parameters, phpDocumentor will ignore them [Parse Data] ;; title of all the documentation ;; legal values: any string title = ThemaMap ;; parse files that start with a . like .bash_profile ;; legal values: true, false hidden = false ;; show elements marked @access private in documentation by setting this to on ;; legal values: on, off parseprivate = on ;; parse with javadoc-like description (first sentence is always the short description) ;; legal values: on, off javadocdesc = off ;; add any custom @tags separated by commas here ;; legal values: any legal tagname separated by commas. ;customtags = mytag1,mytag2 ;; This is only used by the XML:DocBook/peardoc2 converter defaultcategoryname = Documentation ;; what is the main package? ;; legal values: alphanumeric string plus - and _ ;defaultpackagename = phpDocumentor defaultpackagename = DataManagement ;; output any parsing information? set to on for cron jobs ;; legal values: on ;quiet = on ;; parse a PEAR-style repository. Do not turn this on if your project does ;; not have a parent directory named "pear" ;; legal values: on/off ;pear = on ;; where should the documentation be written? ;; legal values: a legal path target = doc/apidoc ;; Which files should be parsed out as special documentation files, such as README, ;; INSTALL and CHANGELOG? This overrides the default files found in ;; phpDocumentor.ini (this file is not a user .ini file, but the global file) readmeinstallchangelog = README, INSTALL, CHANGELOG, NEWS, FAQ, LICENSE ;; limit output to the specified packages, even if others are parsed ;; legal values: package names separated by commas ;packageoutput = package1,package2 ;; comma-separated list of files to parse ;; legal values: paths separated by commas ;filename = /path/to/file1,/path/to/file2,fileincurrentdirectory filename = Bin.php,Classification.php,Distribution.php,Color.php,ColorLut.php ;; comma-separated list of directories to parse ;; legal values: directory paths separated by commas ;directory = /path1,/path2,.,..,subdirectory ;;directory=. ;directory = /home/jeichorn/cvs/pear ;;directory = /home/cellog/pear/PhpDocumentor ;; template base directory (the equivalent directory of /phpDocumentor) ;templatebase = /path/to/my/templates ;; directory to find any example files in through @example and {@example} tags ;examplesdir = /path/to/my/templates ;; comma-separated list of files, directories or wildcards ? and * (any wildcard) to ignore ;; legal values: any wildcard strings separated by commas ;ignore = /path/to/ignore*,*list.php,myfile.php,subdirectory/ ignore = pear-*,templates/,Documentation/,test*.php,Lexer.inc sourcecode = on ;; comma-separated list of Converters to use in outputformat:Convertername:templatedirectory format ;; legal values: HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib, ;; HTML:frames:earthli, ;; HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de, ;; HTML:frames:DOM/phphtmllib,HTML:frames:DOM/earthli ;; HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS ;; PDF:default:default,CHM:default:default,XML:DocBook/peardoc2:default ;output=HTML:frames:earthli,HTML:frames:default,HTML:frames:l0l33t,HTML:frames:phpdoc.de,HTML:frames:phphtmllib,HTML:frames:DOM/default,HTML:frames:DOM/l0l33t,HTML:frames:DOM/phpdoc.de,HTML:frames:DOM/earthli,HTML:frames:DOM/phphtmllib,HTML:frames:phpedit,HTML:Smarty:default,HTML:Smarty:PHP,HTML:Smarty:HandS output=HTML:Smarty:HandS ;; turn this option on if you want highlighted source code for every file ;; legal values: on/off sourcecode = on themamap-0.41/Classification.php0000755000175000017500000000436210631552205020013 0ustar dcorpatauxdcorpatauxbins = $bins; } /** * @return int[] Number of values in every bins */ public function getNbValArray() { $values = array(); foreach($this->bins as $b) { array_push($values, $b->getNbVal()); } return $values; } /** * @return array Label of every bins */ public function getLabelsArray() { $labels = array(); foreach($this->bins as $b) { array_push($labels, $b->getLabel()); } return $labels; } /** * @return numeric[] Return bounds of bins */ public function getBoundsArray() { $bounds = array(); foreach($this->bins as $b) { array_push($bounds, $b->getLowerBound()); } if (count($this->bins) > 0) { array_push($bounds,end($this->bins)->getUpperBound()); } return $bounds; } public function getBins() { return $this->bins; } } ?>themamap-0.41/ColorLut.php0000755000175000017500000001443610603177011016623 0ustar dcorpatauxdcorpatauxinitialColors = $initialColors; } /** * This method is initialized with the two first color * of $initialColors * @param int $nbColors Length of the ColorRgb Array to return * @return ColorRgb[] ColorRgb Array */ public function getColorsArrayByRgbInterpolation($nbColors) { $resultColors = array(); $colorA = $this->initialColors[0]->getColorRgb(); $colorB = $this->initialColors[1]->getColorRgb(); $colorAVal = $colorA->getRgbArray(); $colorBVal = $colorB->getRgbArray(); if($nbColors == 1) { return array($colorA); } for($i=0;$i<$nbColors;$i++) { $rgbTriplet = array(); $rgbTriplet[0] = $colorAVal[0] + $i*($colorBVal[0]-$colorAVal[0])/($nbColors-1); $rgbTriplet[1] = $colorAVal[1] + $i*($colorBVal[1]-$colorAVal[1])/($nbColors-1); $rgbTriplet[2] = $colorAVal[2] + $i*($colorBVal[2]-$colorAVal[2])/($nbColors-1); $resultColors[$i] = new ColorRgb(intval($rgbTriplet[0]), intval($rgbTriplet[1]), intval($rgbTriplet[2])); } return $resultColors; } /** * This method is initialized with the two first color * of $initialColors * @param int $nbColors Length of the ColorRgb Array to return * @param bool $wideHueInterpolation Is interpolation of hue value must be done on the longest path ? * @return ColorRgb[] ColorRgb Array */ public function getColorsArrayByHsvInterpolation($nbColors, $wideHueInterpolation = true) { $resultColors = array(); $colorA = $this->initialColors[0]->getColorHsv(); $colorB = $this->initialColors[1]->getColorHsv(); $colorAVal = $colorA->getHsvArray(); $colorBVal = $colorB->getHsvArray(); if($nbColors == 1) { return array($colorA); } for($i=0;$i<$nbColors;$i++) { $hsvTriplet = array(); if( (abs($colorBVal[0]-$colorAVal[0]) >= 180 && $wideHueInterpolation) || (abs($colorBVal[0]-$colorAVal[0]) < 180 && !$wideHueInterpolation)) { $hsvTriplet[0] = $colorAVal[0] + $i*($colorBVal[0]-$colorAVal[0])/($nbColors-1); } else { $hsvTriplet[0] = $colorAVal[0] + $i*(($colorBVal[0]-$colorAVal[0])-360.0)/($nbColors-1); } if($hsvTriplet[0] < 0.0) {$hsvTriplet[0] += 360.0;} if($hsvTriplet[0] >= 360.0) {$hsvTriplet[0] -= 360;} $hsvTriplet[1] = $colorAVal[1] + $i*($colorBVal[1]-$colorAVal[1])/($nbColors-1); $hsvTriplet[2] = $colorAVal[2] + $i*($colorBVal[2]-$colorAVal[2])/($nbColors-1); $resultColors[$i] = new ColorHsv(floatval($hsvTriplet[0]), floatval($hsvTriplet[1]), floatval($hsvTriplet[2])); } return $resultColors; } /** * This method is initialized with the first color * of $initialColors * Saturation and Value stay constant * This is an appropriate methode for discrete value * Result are best when Value is high * @param int $nbColors Length of the ColorRgb Array to return * @return ColorHsv[] ColorRgb Array */ public function getColorsHsvArrayWithMaxDifference($nbColors) { $resultColors = array(); $colorA = $this->initialColors[0]->getColorHsv(); $colorAVal = $colorA->getHsvArray(); $deltaHue = 360.0/$nbColors; if($nbColors == 1) { return array($colorA); } for($i=0;$i<$nbColors;$i++) { $hue = $colorAVal[0] + $i*$deltaHue; if($hue >= 360.0) {$hue -= 360;} $resultColors[$i] = new ColorHsv(floatval($hue), floatval($colorAVal[1]), floatval($colorAVal[2])); } return $resultColors; } /** * @param integer $method Method name constant as define in this class * @return Color[] */ public function getColorsByWellKnownMethod($method,$nbColors, $wideHueInterpolation = false) { switch($method) { case ColorLut::METHOD_RGB_INTERPOLATION : $colors = $this->getColorsArrayByRgbInterpolation($nbColors); break; case ColorLut::METHOD_HSV_INTERPOLATION : $colors = $this->getColorsArrayByHsvInterpolation($nbColors, $wideHueInterpolation); break; case ColorLut::METHOD_MAX_DIFFERENCE : $colors = $this->getColorsHsvArrayWithMaxDifference($nbColors); break; } return $colors; } } ?>themamap-0.41/Distribution.php0000755000175000017500000002037110631552205017535 0ustar dcorpatauxdcorpatauxnbVal = $distribution->getNbVal(); $this->minVal = $distribution->getMin(); $this->maxVal = $distribution->getMax(); $this->meanVal = $distribution->getMean(); $this->stdDevVal = $distribution->getStdDev(); } } /** * @package DataManagement */ class Distribution { const CLASSIFY_WITH_BOUNDS = 0; const CLASSIFY_BY_EQUAL_INTERVALS = 1; const CLASSIFY_BY_QUANTILS = 2; const CLASSIFY_BY_MODES = 3; /** * This array contains values of the distribution. */ protected $values = array(); /** * @var int */ protected $nbVal; protected $minVal; protected $maxVal; protected $meanVal; protected $stdDevVal; /** * @param array $values All values must be passed at construction * @return void */ public function __construct ($values) { $this->values = $values; $this->nbVal = count($this->values); $this->minVal = $this->nbVal ? min($this->values) : 0; $this->maxVal = $this->nbVal ? max($this->values) : 0; $this->meanVal = $this->nbVal ? array_sum($this->values)/$this->nbVal : 0; $stdDevNum = 0; foreach($values as $val) { $stdDevNum += pow($val - $this->meanVal,2); } if ($this->nbVal > 1) { $this->stdDevVal = sqrt($stdDevNum/($this->nbVal-1)); } else { $this->stdDevVal = NULL; } } /** * @return mixed */ public function getValues() { return $this->values; } /** * @return int */ public function getNbVal() { return $this->nbVal; } /** * @return mixed */ public function getMin() { return $this->minVal; } /** * @return mixed */ public function getMax() { return $this->maxVal; } /** * @return mixed */ public function getMean() { return $this->meanVal; } /** * @return mixed */ public function getStdDev() { return $this->stdDevVal; } /** * @param mixed[] $bounds Bounds of classes * We suppose that every value is within min($bounds) * and max($bounds) * @return Classification */ public function classifyWithBounds($bounds) { $bins = array(); $binCount = array(); $sortedValues = $this->values; $nbBins = count($bounds)-1; sort($sortedValues); for($i=0;$i<($nbBins);$i++) { $binCount[$i] = 0; } for($i=0;$i<($nbBins-1);) { if(isset($sortedValues[0]) && $sortedValues[0] < $bounds[$i+1]) { $binCount[$i]=$binCount[$i] + 1; array_shift($sortedValues); } else { $i++; } } $binCount[$nbBins-1] = $this->nbVal-array_sum($binCount); for($i=0;$i<($nbBins);$i++) { $label = $bounds[$i] . '-' . $bounds[$i+1]; $bins[$i] = new Bin($binCount[$i], $label, $bounds[$i], $bounds[$i+1], $i==($nbBins-1)); } return new Classification($bins); } /** * @return Classification */ public function classifyByEqIntervals($nbBins) { $bounds = array(); for($i=0; $i<=$nbBins; $i++) { $bounds[$i] = $this->minVal + $i*($this->maxVal-$this->minVal)/$nbBins; } return $this->classifyWithBounds($bounds); } /** * @return Classification */ public function classifyByQuantils($nbBins) { $values = $this->values; sort($values); $binSize = round(count($this->values) / $nbBins); $bounds = array(); $binLastValPos = $binSize == 0 ? 0 : ($binSize); if (count($values) > 0) { $bounds[0] = $values[0]; for ($i = 1 ; $i < $nbBins ; $i++) { $bounds[$i] = $values[$binLastValPos]; $binLastValPos += $binSize; } $bounds[] = $values[count($values)-1]; } return $this->classifyWithBounds($bounds); } /** * Returns n-1 classes for the n-1 modes of the distribution and an * "other" class. * This method will fail if type is different of int or string * You may disable the other class * @param int $nbBins Number of classes required * @param bool $ClassOther Enable "Other" class (default) * @return Classification */ public function classifyByModes($nbBins, $ClassOther=true) { $countValues = array_count_values($this->values); arsort($countValues); $countValuesId = array_keys($countValues); $countValuesNb = array_values($countValues); $bins = array(); $sum = 0; for($i=0;$i<($nbBins-1);$i++) { $bins[] = new Bin($countValuesNb[$i], $countValuesId[$i]); $sum += $countValuesNb[$i]; } if($ClassOther == true) { $bins[] = new Bin($this->nbVal-$sum,'Others'); } else { $bins[] = new Bin($countValuesNb[$nbBins-1], $countValuesId[$nbBins-1]); } return new Classification($bins); } /** * @return integer Maximal number of classes according to the Sturge's rule */ public function sturgesRule() { return intval(floor(1 + 3.3 * log($this->nbVal,10.0))); } /** * @return integer Maximal number of classes according to the Yule's rule */ public function yulesRule() { return intval(floor(2.5*pow($this->nbVal,0.25))); } /** * This function calls the appropriate classifyBy... function. * The name of classification methods are defined by class constants * @param integer $method Method name constant as define in this class * @param integer $nbBins Number of classes * @param array $bounds Bounds of classification * @return Classification */ public function classify( $method = Distribution::CLASSIFY_BY_EQUAL_INTERVALS, $nbBins = NULL, $classOther = true, $bounds = array()) { if(is_null($nbBins)) { $nbBins = $this->sturgesRule(); } switch($method) { case Distribution::CLASSIFY_WITH_BOUNDS : $classification = $this->classifyWithBounds($bounds); break; case Distribution::CLASSIFY_BY_EQUAL_INTERVALS : $classification = $this->classifyByEqIntervals($nbBins); break; case Distribution::CLASSIFY_BY_QUANTILS : $classification = $this->classifyByQuantils($nbBins); break; case Distribution::CLASSIFY_BY_MODES : $classification = $this->classifyByModes($nbBins, $classOther); } return $classification; } } ?>themamap-0.41/README0000644000175000017500000000065210603177011015217 0ustar dcorpatauxdcorpatauxThemaMap offers functionnalities for thematic mapping. It must be use with a separate mapping engine (eg. Mapserver). *** Building API documentation * Install PhpDocumentor via pear # pear upgrade PhpDocumentor-beta * In the current directory, run $ phpdoc -c doc/apidoc-config.ini *** Running automatic tests * Install PHPUnit2 via pear # pear install PHPUnit2 * In the directory tests, run $ phpunit AllTests.php themamap-0.41/tests/0000755000175000017500000000000010637754774015526 5ustar dcorpatauxdcorpatauxthemamap-0.41/tests/AllTests.php0000755000175000017500000000265110603177011017751 0ustar dcorpatauxdcorpatauxaddTestSuite('ColorTest'); $suite->addTestSuite('ColorLutTest'); $suite->addTestSuite('DistributionTest'); return $suite; } } ?>themamap-0.41/tests/ColorLutTest.php0000755000175000017500000000760310603177011020623 0ustar dcorpatauxdcorpatauxrgbColorA = new ColorRgb(226,53,39); $this->rgbColorB = new ColorRgb(54,38,211); $this->hsvColorA = new ColorHsv(256.0,0.73,0.69); $this->hsvColorB = new ColorHsv(97.0,0.79,0.80); $this->hsvColorC = new ColorHsv(100.0,0.50,0.50); $this->hsvColorD = new ColorHsv(200.0,0.80,0.80); } public function testGetColorsArrayByRgbInterpolation() { $initialColors = array($this->rgbColorA,$this->rgbColorB); $colorLut = new ColorLut($initialColors); $resultRgb = $colorLut->getColorsArrayByRgbInterpolation(3); $this->assertTrue($this->rgbColorA->equals($resultRgb[0])); $this->assertTrue($this->rgbColorB->equals($resultRgb[2])); } public function testGetColorsArrayByHsvInterpolation() { $initialColors = array($this->hsvColorA,$this->hsvColorB); $colorLut = new ColorLut($initialColors); $resultHsv = $colorLut->getColorsArrayByRgbInterpolation(3); $this->assertTrue($this->hsvColorA->equals($resultHsv[0])); $this->assertTrue($this->hsvColorB->equals($resultHsv[2])); $initialColors = array($this->hsvColorC,$this->hsvColorD); $colorLut = new ColorLut($initialColors); $resultHsv = $colorLut->getColorsArrayByHsvInterpolation(3,false); $color1 = new ColorHsv(150.0,0.65,0.65); $this->assertTrue($color1->equals($resultHsv[1])); $resultHsv2 = $colorLut->getColorsArrayByHsvInterpolation(3,true); $color2 = new ColorHsv(330.0,0.65,0.65); $this->assertTrue($color1->equals($resultHsv[1])); } public function testGetColorsHsvArrayWithMaxDifference() { $initialColors = array($this->hsvColorA,$this->hsvColorB); $colorLut = new ColorLut($initialColors); $resultHsv = $colorLut->getColorsArrayByRgbInterpolation(3); $this->assertTrue($this->hsvColorA->equals($resultHsv[0])); } public function testOneColorRequestRgb() { $initialColors = array(new ColorRgb(0,0,0), new ColorRgb(0,0,0)); $colorLut = new ColorLut($initialColors); $rgbInterp = $colorLut->getColorsArrayByRgbInterpolation(1); $this->assertEquals(1,count($rgbInterp)); } public function testOneColorRequestHsv() { $initialColors = array(new ColorRgb(0,0,0), new ColorRgb(0,0,0)); $colorLut = new ColorLut($initialColors); $hsvInterp = $colorLut->getColorsArrayByHsvInterpolation(1); $this->assertEquals(1,count($hsvInterp)); } public function testOneColorRequestMaxDifference() { $initialColors = array(new ColorRgb(0,0,0), new ColorRgb(0,0,0)); $colorLut = new ColorLut($initialColors); $maxInterp = $colorLut->getColorsHsvArrayWithMaxDifference(1); $this->assertEquals(1,count($maxInterp)); } } ?>themamap-0.41/tests/ColorTest.php0000755000175000017500000000747410603177011020144 0ustar dcorpatauxdcorpatauxassertEquals(floatval($firstColor->getColorRgb()->getRedLevel()), floatval($secondColor->getColorRgb()->getRedLevel()), '', $delta = 1.1); $this->assertEquals(floatval($firstColor->getColorRgb()->getGreenLevel()), floatval($secondColor->getColorRgb()->getGreenLevel()), '', $delta = 1.1); $this->assertEquals(floatval($firstColor->getColorRgb()->getBlueLevel()), floatval($secondColor->getColorRgb()->getBlueLevel()), '', $delta = 1.1); } protected function assertEqualHsvColors($firstColor,$secondColor) { $this->assertEquals(floatval($firstColor->getColorHsv()->getHueLevel()), floatval($secondColor->getColorHsv()->getHueLevel()), '', $delta = 1.1); $this->assertEquals(floatval($firstColor->getColorHsv()->getSaturationLevel()), floatval($secondColor->getColorHsv()->getSaturationLevel()), '', $delta = 0.011); $this->assertEquals(floatval($firstColor->getColorHsv()->getValueLevel()), floatval($secondColor->getColorHsv()->getValueLevel()), '', $delta = 0.011); } protected function setUp() { $this->rgbBlack = new ColorRgb(0,0,0); $this->rgbWhite = new ColorRgb(255,255,255); $this->rgbGray = new ColorRgb(100,100,100); $this->rgbColorA = new ColorRgb(82,47,176); $this->rgbColorB = new ColorRgb(104,205,43); $this->hsvBlack = new ColorHsv(0.0,0.0,0.0); $this->hsvWhite = new ColorHsv(0.0,0.0,1.0); $this->hsvGray = new ColorHsv(0.0,0.0,0.39); $this->hsvColorA = new ColorHsv(256.0,0.73,0.69); $this->hsvColorB = new ColorHsv(97.0,0.79,0.80); } public function testRgb2Hsv() { $this->assertEqualHsvColors($this->rgbBlack,$this->hsvBlack); $this->assertEqualHsvColors($this->rgbWhite,$this->hsvWhite); $this->assertEqualHsvColors($this->rgbGray,$this->hsvGray); $this->assertEqualHsvColors($this->rgbColorA,$this->hsvColorA); $this->assertEqualHsvColors($this->rgbColorB,$this->hsvColorB); } public function testHsv2Rgb() { $this->assertEqualRgbColors($this->rgbBlack,$this->hsvBlack); $this->assertEqualRgbColors($this->rgbWhite,$this->hsvWhite); $this->assertEqualRgbColors($this->rgbGray,$this->hsvGray); $this->assertEqualRgbColors($this->rgbColorA,$this->hsvColorA); $this->assertEqualRgbColors($this->rgbColorB,$this->hsvColorB); } public function testColorEquals() { $this->assertTrue($this->rgbBlack->equals($this->rgbBlack)); $this->assertTrue($this->rgbBlack->equals($this->hsvBlack)); $this->assertTrue($this->hsvColorA->equals($this->hsvColorA)); $this->assertFalse($this->hsvWhite->equals($this->rgbColorB)); } } ?>themamap-0.41/tests/DistributionTest.php0000755000175000017500000001471710603177011021543 0ustar dcorpatauxdcorpatauxassertEquals(1,$distrib->getMin()); $this->assertEquals(9,$distrib->getMax()); $this->assertEquals(5,$distrib->getMean()); $this->assertEquals(sqrt(7.5), $distrib->getStdDev()); $this->assertEquals(9, $distrib->getNbVal()); $this->assertEquals(array(1,2,3,4,5,6,7,8,9), $distrib->getValues()); } public function testClassifyWithBounds() { $a2 = array(0,1,2,10,11,100,200,300,1000,1000); $bounds = array(0,10,100,1000); $distrib = new Distribution($a2); $classification = $distrib->classifyWithBounds($bounds); $nbValues = $classification->getNbValArray(); $this->assertEquals(3,count($nbValues)); $this->assertEquals(3,$nbValues[0]); $this->assertEquals(2,$nbValues[1]); $this->assertEquals(5,$nbValues[2]); } public function testClassifyByEqIntervals() { $a1 = array(0.0,1.0,2.0,2.0,3,4,5,7,8,10,11,11.5,12.0); $distrib = new Distribution($a1); $classification = $distrib->classifyByEqIntervals(4); $nbValues = $classification->getNbValArray(); $this->assertEquals(4,count($nbValues)); $this->assertEquals(4,$nbValues[0]); $this->assertEquals(3,$nbValues[1]); $this->assertEquals(2,$nbValues[2]); $this->assertEquals(4,$nbValues[3]); } public function testClassifyByQuantils() { $a1 = array(0.0,1.0,2.0,2.0,3,4,5,7,8,10,11,11.5,12.0); $distrib = new Distribution($a1); $classification = $distrib->classifyByQuantils(4); $nbValues = $classification->getNbValArray(); $this->assertEquals(4,count($nbValues)); $this->assertEquals(2,$nbValues[0]); $this->assertEquals(4,$nbValues[1]); $this->assertEquals(3,$nbValues[2]); $this->assertEquals(4,$nbValues[3]); $a2 = range(1,12); $distrib = new Distribution($a2); $classification = $distrib->classifyByQuantils(4); $nbValues = $classification->getNbValArray(); $this->assertEquals(4,count($nbValues)); $this->assertEquals(3,$nbValues[0]); $this->assertEquals(3,$nbValues[1]); $this->assertEquals(3,$nbValues[2]); $this->assertEquals(3,$nbValues[3]); } public function testClassifyByModes() { $a1 = array(1,1,1,1,2,3,3,3,4,4,7,8); $distrib1 = new Distribution($a1); $classification = $distrib1->classifyByModes(3); $nbValues = $classification->getNbValArray(); $labels = $classification->getLabelsArray(); $this->assertEquals(3,count($nbValues)); $this->assertEquals(4,$nbValues[0]); $this->assertEquals(3,$nbValues[1]); $this->assertEquals(5,$nbValues[2]); $this->assertEquals(1,$labels[0]); $this->assertEquals(3,$labels[1]); $this->assertEquals('Others',$labels[2]); $a2 = array('bonjour','salut','allo','bonsoir','salut','salut','salut', 'allo','allo'); $distrib2 = new Distribution($a2); $classification = $distrib2->classifyByModes(2, false); $nbValues = $classification->getNbValArray(); $labels = $classification->getLabelsArray(); $this->assertEquals(2,count($nbValues)); $this->assertEquals(4,$nbValues[0]); $this->assertEquals(3,$nbValues[1]); $this->assertEquals('salut',$labels[0]); $this->assertEquals('allo',$labels[1]); } public function testClassifyByModes2() { $a1 = array(1,1,1,1,2,3,3,3,4,4,7,8); $distrib1 = new Distribution($a1); $classification = $distrib1->classify( $method = Distribution::CLASSIFY_BY_MODES, $nbBins =3); $nbValues = $classification->getNbValArray(); $labels = $classification->getLabelsArray(); $this->assertEquals(3,count($nbValues)); $this->assertEquals(4,$nbValues[0]); $this->assertEquals(3,$nbValues[1]); $this->assertEquals(5,$nbValues[2]); $this->assertEquals(1,$labels[0]); $this->assertEquals(3,$labels[1]); $this->assertEquals('Others',$labels[2]); } public function testSturgesRule() { $a1 = range(1,10); $a2 = range(1,100); $a3 = range(1,1000); $distrib1 = new Distribution($a1); $distrib2 = new Distribution($a2); $distrib3 = new Distribution($a3); $this->assertEquals(4,$distrib1->sturgesRule()); $this->assertEquals(7,$distrib2->sturgesRule()); $this->assertEquals(10,$distrib3->sturgesRule()); } public function testYulesRule() { $a1 = range(1,10); $a2 = range(1,100); $a3 = range(1,1000); $distrib1 = new Distribution($a1); $distrib2 = new Distribution($a2); $distrib3 = new Distribution($a3); $this->assertEquals(4,$distrib1->yulesRule()); $this->assertEquals(7,$distrib2->yulesRule()); $this->assertEquals(14,$distrib3->yulesRule()); } public function testOneDataDistrib() { $a = array(1); $distrib = new Distribution($a); $classification = $distrib->classifyByQuantils($distrib->sturgesRule()); $labels = $classification->getLabelsArray(); $this->assertEquals(1,count($classification->getNbValArray())); $this->assertEquals('1-1',$labels[0]); } } ?>