Google Answers Logo
View Question
 
Q: PHP - Binary Data Parsing ( No Answer,   0 Comments )
Question  
Subject: PHP - Binary Data Parsing
Category: Computers > Programming
Asked by: ciagon-ga
List Price: $10.00
Posted: 21 Jun 2002 17:41 PDT
Expires: 28 Jun 2002 17:41 PDT
Question ID: 31405
I have a database of polygons, and the points are stored in a blob.  I
need the get the data into a php array.  Each point is a pair of
(64bit) doubles for lat and lon.

Here is the prototype for the function:

	// $num_points = Number of points
	// $blob_data = A big string.  Size is (16*$num_points) chars
	// $array = array to be outputed.  You can remove this, and
	//   return the array if you want.
	function convert_blob_to_array($num_points, $blob_data, $array) {

	}

Here is a file containing 100 points in the specified format:

	www.ciagon.com/blob.dat

Here is a c script that generated the file:

	#include <stdlib.h>
	#include <stdio.h>

	typedef struct {
	        double lat;
	        double lon;
	} point;

	int main() {
	        point mypoint;
	        int i;
	        for(i=0; i<100; i++) {
	                mypoint.lat = i;
	                mypoint.lon = (100 - i);
	                fwrite(&mypoint, 1, sizeof(mypoint), stdout);
	        }
	        return 0;
	}

I prefer a fast algorithm or an elegant solution.  Please do not use
popen() and an external program, because it won't be much faster than
my current solution.  Code alone is sufficient for an answer.

If the formatting gets messed up, view this question here:
www.ciagon.com/blob.html
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy