JPGraph Lineplot SetFillColor Upwards - php

Is there any way to set a LinePlot->SetFillColor to go upwards instead of going down in JPGraph - PHP?
$p6 = new LinePlot($arrayLimSpecI);
$graph->Add($p6);
$p6->SetColor("#0B610B");
$p6->SetWeight(3);
$p6->SetStyle("solid");
//FillColor Fills the plotline from point 0 to point X
$p6->SetFillColor('red#0.65');
What I've tried:
$band = new PlotBand(HORIZONTAL,BAND_SOLID,$valueS,"max",'red');
$band->ShowFrame(false);
$graph->AddBand($band);
But this band doesn't seem to adjust to the dynamic marks that the graphic has got. If I set valueS to show on Y-Mark 10 it will show instead on the mark point 40.
EDIT: Another library that is currently supported or is capable or doing this is welcomed.

Related

Exifs image, convert ExposureProgram number

I need to upload images and get Exif to display.
I'm using exif_read_data to get exifs data.
$data = exif_read_data($imageFile, 'EXIF', true);
Everything is fine, but :
$data['EXIF']['ExposureProgram'] = 3
I know Exposure Programm could be :
aperture priority
shutter priority
auto
manuel
I don't find any information about this number and what is its meaning.
Maybe someone can help me here ?
Thanks
Why not checking Exif's Standard 2.32 itself? Page 50:
0 = Not defined
1 = Manual
2 = Normal program
3 = Aperture priority
4 = Shutter priority
5 = Creative program (biased toward depth of field)
6 = Action program (biased toward fast shutter speed)
7 = Portrait mode (for closeup photos with the background out of focus)
8 = Landscape mode (for landscape photos with the background in focus)
Other = reserved
Phil Harvey's ExifTool reference is also worth to check for additional improper values from vendors violating the standard(s):
(the value of 9 is not standard EXIF, but is used by the Canon EOS 7D)
9 = Bulb

find every possible path in a non oriented graph and weighted

I want to find every possible path in a NON oriented but weighted graph
I have made some search on dijkstra, but I'm only able to find the shortest path, even by looking in the code, i'm not able to find every path (i think it's because of the method used by dijkstra to not search every path)
I know the beginning point, but not the ending point, all I want is no more than X (in weight) in my path (and of the course ALL the path < X)
Let say I have this array to define my point (in php):
$aRoutes = array(
array(0,0,0),
array(0,1,10),
array(0,2,20),
array(0,3,30),
array(0,4,100),
array(1,1,0),
array(1,2,50),
array(1,3,15),
array(1,4,10),
array(2,2,0), //2->3 is below in the form 3->2
array(2,4,10),
array(3,3,0),
array(3,2,20),//but it's not oriented !
array(3,4,60),
array(4,4,0)
);
As you can see, every step have 4 paths reachable.
Now, beginning with step 0, I want to know every path that is less than 50 (if I can have every "longest" that would be the best code ! :) )
In our case every path can be :
0->1 = 10
0->1->3 = 25
0->1->3->2 = 45
0->1->4 = 20
0->1->4->2 = 30
0->1->4->2->3 = 50
0->2 = 20
0->2->3 = 40
0->2->4 = 30
0->3 = 30
0->3->1 = 45
0->3->2 = 50
As you can see, the "best" one is 0->1->4->2->3 = 50
(pretty easy to know as it's the longest one)
I'm pretty bad in recursive coding, so that's why I ask your help (i barelly understand what is done in every dijkstra code i have found)
(can be coded in php, java, vb, c, c++, I understand every one and i'm able to translate it once I have it...a little preference for php :p )
Thank in advance for your help

PChart - Y Axis does not start from 0

I generate stacked bar chart using PChart, but Y Axis does not start from 0.
Is there manual parameter that I should set? Here the chart
$graph->drawScale(array("Mode" => SCALE_MODE_START0));
This works for standard bar charts, I assume it would work for stacked. Give it a try.
There are actually a couple of ways to solve this issue. According to the documentation you should be able to use:
$graph->drawScale(array("Mode"=> SCALE_MODE_ADDALL_START0));
however, when I was generating stacked charts, it kept adding an additional mark at 110%, to solve this I decided to use:
$scaleProperties = array(0=>("Min"=>0, "Max"=>100));
$graph->drawScale(array("Mode" => SCALE_MODE_MANUAL, "ManualScale"=>$scaleProperties));
You would simply change the "Max" value to whatever your top end is, this forces the scale to stay between 0 and the maximum value.

geoPHP point in polygon

i need some help, google makes me sad
I got polygon http://geojson.io/#id=gist:anonymous/069b8a955897723ca256&map=4/58.75/48.03
And it covering a lot.
And i got geoPHP library https://github.com/phayes/geoPHP
Which got methods contains, covers, coveredBy...
And everything is normal, except that point like 74.224074, 96.428248 is always false for methods contains,coveredBy,covers, etc for this polygon. But it must be true.
Please, tell me why. I got a headache.
OR
Tell me please, how check that the lat lng is inside polygon. I tested about 3 libraries in perl and php, making my own code, etc... But the right results i got only from google containsLocation in javascript. But i have to use it on server side, not in browser. If there any chance to use containsLocation in nodejs it would be very nice.
Thank you
A little code for geoPHP:
$a='JSON FROM LINK';
$b=geoPHP::load("POINT(74.224074 96.428248)","wkt");
$a=geoPHP::load($a, 'json');
$result=$a->contains($b);
var_dump($result);
And it will be false
EDIT:
I think i got it.
GeoJson making coordinates in wrong way, longtitude, latitude. But it must be latitude, longtitude.
Will try and then write here if it works
ANSWER:
Use this www.birdtheme.org/useful/v3tool.html to make polygon on maps. It making it in right way(latitude,longtitude)
Working code for geoPHP:
include_once('geoPHP.inc');
$addr=file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address='.urlencode($_GET['address']).'&sensor=false');
foreach($addr->{results} as $addr1)
{
if(array_key_exists("geometry",$addr1)){
$lat=$addr1->{geometry}->{location}->{lat};
$lng=$addr1->{geometry}->{location}->{lng};
break;
}
}
$point1 = geoPHP::load("POINT($lat $lng)","wkt");
$ya200=geoPHP::load("POLYGON((41.51 12.3, 38.27 28.83, 32.55 41.84, 27.6 55.55, 29.54 71.37, 33.43 83.32, 36.6 94.92, 36.6 99.49, 35.17 111.45, 32.55 124.8, 35.17 130.78, 39.64 142.73, 43.58 152.58, 45.83 166.29, 56.17 163.83, 63.07 159.26, 68.66 154.69, 72.18 148.71, 75.93 140.63, 78.49 129.02, 80.3 114.26, 80.98 100.2, 81.2 87.54, 80.87 73.83, 79.62 59.41, 76.27 40.43, 71.07 28.13, 67.2 23.2, 63.55 20.04, 59.01 17.23, 54.16 15.12, 48.46 13.36,41.51 12.3))","wkt");
var_dump($ya200->contains($point1));
I am the maintainer of the geoPHP library (https://geophp.net). You have your latitude and longitude mixed up. WKT specifies that x comes first, then y, and then (optionally) z. This makes sense, as we usually do things in XYZ order.
It's conventional in mathematics for the horizontal axis to be X, and the vertical axis to be Y. If we think of a globe overlaid on a piece of graphing paper with X and Y axes specified, we can see that longitude is the horizontal axis, which corresponds to X, and the latitude is the vertical axis, which corresponds to Y. Therefore reading it as "longitude, latitude" makes perfect sense.
Regrettably, this sensical approach is backwards from the way mariners and other cartographers have described coordinates on the globe it throughout history. Historically it has often been described as "latitude, longitude".
This clash of history vs mathematical-convention is why you see different conventions in different systems. In Google Maps API its "latitude, longitude", while in OpenLayers it's "longitude, latitude".
In this particular case, you are using WKT, which is specified in "longitude, latitude" order.
WKT format expects POINT(lon, lat), with lon being first. You mixed up the order. Corrected:
geoPHP::load("POINT($lon $lat)","wkt");
I have answered almost the same question but don't know how to make a repost of it, so I just repeat it here (sorry)
If you use this PHP library (https://github.com/xopbatgh/sb-polygon-pointer), it may do all you need
(but first you need to convert GEOjson coordinates to lat/lng)
Plan to do:
Insert the coordinates of your polygon into array
Ask the library is the any point with lat/lng inside this polygon
$polygonBox = [
[55.761515, 37.600375],
[55.759428, 37.651156],
[55.737112, 37.649566],
[55.737649, 37.597301],
];
$sbPolygonEngine = new sbPolygonEngine($polygonBox);
$isCrosses = $sbPolygonEngine->isCrossesWith(55.746768, 37.625605);
// $isCrosses is boolean
After hours of struggle, I could not get the contains method to work with geoPHP. It turns out, as pointed out from this SO response that the geos library needs to be installed manually (no composer), which I could not get working after sifting through documentation on archive.org.
As an alternative, I found the mjaschen/phpgeo to be simple to use to do polygon contains point calculations. Simply load in your lat lons to objects and call the contains method as outlined in the documentation:
$polygon = new Polygon();
$polygon->addPoint(new Coordinate(12.3, 41.51));
$polygon->addPoint(new Coordinate(28.83, 38.27));
$polygon->addPoint(new Coordinate(41.84, 32.55));
$point = new Coordinate(74.224074, 96.428248)
var_dump($polygon->contains($point))
All advanced methods in geoPHP requires that GEOS is installed. If You are not able to install it but still want to use intersects test for point and polygon, then I have forked geoPHP and added Polygon->pointInPolygon and MultiPolygon->pointInPolygon methods for that purpose. Take a look:
https://github.com/sookoll/geoPHP
$point = \geoPHP::load('POINT (x y)','wkt');
$polygon = \geoPHP::load('POLYGON ((x y...))','wkt');
$point_is_in_polygon = $polygon->pointInPolygon($point);

PHP convert 12digit hex to 6

I am parsing a XML file supplied by some software. Part of the parsing is extracting colors from some attributes. The problem I have is the color is a 12digit hex value. ie,
<Text AdornmentStyle="0" Background="#FFFFFFFFFFFF" Color="#DD6B08C206A2" Font="Courier Final Draft" RevisionID="0" Size="12" Style="">Test</Text>
As you can see the colors are 12digits long. I need to get the 6 digit color so I can display it correctly on html.
Has anyone come across this before?
Hope you can advise.
Never seen a 12-digit hex color string before. Must be using 2-bytes per channel, which means if you convert it, you're going to lose a bit of information.
I believe the color is in the format #RRRRGGGGBBBB, so take each 4 hexgits and divide by (16^4/16^2)=256, and round if necessary. That should do it.
...and if that doesn't give you the right color, try CMYK like cypher suggests: #CCCMMMYYYKKK (12-bits per channel).
e.g., to convert DD6B08C206A2 do:
0xDD6B / 0x100 = 0xDD
0x08C2 / 0x100 = 0x08
0x06A2 / 0x100 = 0x06
Put those back together and you get #DD0806.

Categories