Moving systems in bulk

Is there any way to move systems in bulk? I've got a map of lots of systems that would be much easier to use if everything was farther apart. I've got a decent idea of how to do this algorithmically considering each system to be a point on a 2-D plane, but I need a way to just feed in a bunch of syst data and return the modified syst data.

Ideas? Do I need to make my own nova editor specifically for this? I don't care too much about keeping the shape of the map, I just want everything spread out a bit, say 2x stretch on either axis.

Algorithm I've thought up (so far, it may need some work)

Initial: Pick a central point by hand and let it be the origin (0,0)

  1. Divide all the points into two groups, above and below the central point (origin).
  2. Move all above points up by <a>
  3. Find the next-closest system on the y axis in the group of systems which was just moved. This is the new central point.
    Repeat 1-3 for +ve y-axis, then -ve y-axes (move down). Then +ve/-ve x-axis (moving left/right).

It may skew the look of the map a bit, but it will make everything easier to read. The algorithm isn't too hard to implement, I just need a way of pulling the following datatype out of a nova file and then putting it back in when done:

I'll post the algorithm code in C++ when I'm done writing it.

Here's what I'm thinking so far. Comments?

int numsys = <number of systems>;
int i; //loop counter
int j; //outer loop counter
int verticalGap; //amount to move vertically
int horizontalGap; //amount to move horizontally

struct systPoint {
    int ID;
    int x;
    int y;
}

//some stuff to load the data into systPoint struct from the nova file - dunno what to use
sysPoint allSys(numsys); //contains all systems, sorted by system ID as imported.

//initialize arrays for sorting
int Up(numsys);
int numUp = 0;
int Down(numsys);
int numDown = 0;
int Right(numsys);
int numRight = 0;
int Left(numsys);
int numLeft = 0;
int Central(numsys);
int numCentral = 0;

//sort systems into left, right, up, down
for(i = 128; i <= (numsys+128); i++)
{
	if(allSys(i).x > 0) {
		Right(numRight) = allSys(i).ID;
		numRight++;
	} else if(allSys(i).x < 0) {
		Left(numLeft) = allSys(i).ID;
		numLeft++;
	}
	
	if(allSys(i).y > 0) {
		Up(numUp) = allSys(i).ID;
		numUp++;
	} else if(allSys(i).y < 0) {
		Down(numDown) = allSys(i).ID;
		numDown++
	}
	
	if(allSys(i).x == 0 && allSys(i).y == 0) {
		Central(numCentral) = allSys(i).ID;
		numCentral++
	}
}


int lastMove = 0;
int nextMove; 
//assume system ID 128 is central system at (0,0)

//first move up
for(j = 0; j < numUp; j++)
{
	nextMove = 32767; //based on the max value a-la EVN
	for(i = 0; i < numUp; i++)
	{
		if(allSys(Up(i)).y > lastMove){
			allSys(Up(i)).y += verticalGap;
			if(allSys(Up(i)).y < nextMove) { //set nextMove to the y coordinate of the lowest system after all the moves.
				nextMove = allSys(Up(i)).y;
			}
		}
	}
	
	lastMove = nextMove;
}

//then repeat for down, left, right.

I don't care much about efficiency, I just want it to work.

I think the easiest way for you to get at the data is ConText/ResStore - it would probably be much more work to write a resource parser, or even to hook your code into anything I could give you.

@david-arthur, on 19 January 2011 - 07:02 PM, said in Moving systems in bulk:

I think the easiest way for you to get at the data is ConText/ResStore - it would probably be much more work to write a resource parser, or even to hook your code into anything I could give you.

I can't run ConText/ResStore (intel mac) or I would have done it without posting here.

Can anyone run ConText/ResStore for me? Much appreciated if you can. Gimme a shout and I'll get you the file.

@DavidArthur: How does MC read files? Could I somehow use MC's resource file loader to get the data into this? Or is it more hassle than its worth?

This post has been edited by LNSU : 19 January 2011 - 07:12 PM

@lnsu, on 19 January 2011 - 07:11 PM, said in Moving systems in bulk:

I can't run ConText/ResStore (intel mac) or I would have done it without posting here.

I have an Intel Mac, and ConText still seems to work for me. :unsure:

@lnsu, on 19 January 2011 - 07:11 PM, said in Moving systems in bulk:

How does MC read files? Could I somehow use MC's resource file loader to get the data into this? Or is it more hassle than its worth?

MissionComputer has a class called Resource which can load any resource (using standard Resource Manager calls) and provides methods for parsing it. For each resource type, there is another class (e.g. DudeResource) which creates a Resource, and uses it to decode that particular type (with a string of commands on the level of Govt = theResource.ReadDWRD); the editor then transfers the data from this class's properties to its interface.

The whole thing is more object-oriented than a courtroom drama, but since it's all based on compiled code it isn't easily extensible unless I implement that macro language I've mused about in less realistic moments. If you re-wrote your code in REALbasic, I could probably run it for you, but ConText still seems so much easier.

I thought ConText was OS9 only. Oops.

It was never Intel-ised, but it seems to work in Rosetta.

I second the ConText/ResStore method. Note that ResStore is quite picky about the format of its input file. After you use ConText and then make your edits in a spreadsheet program, you need to copy and paste back to text editor and save in Western (Mac OS Roman) format with Classic Mac (CR) line breaks. Also I always do a Find for two consecutive tabs and Replace All with a blank string, but I don’t know if that’s strictly necessary.

@qaanol, on 21 January 2011 - 12:38 AM, said in Moving systems in bulk:

I second the ConText/ResStore method. Note that ResStore is quite picky about the format of its input file. After you use ConText and then make your edits in a spreadsheet program, you need to copy and paste back to text editor and save in Western (Mac OS Roman) format with Classic Mac (CR) line breaks. Also I always do a Find for two consecutive tabs and Replace All with a blank string, but I don’t know if that’s strictly necessary.

Thanks for the heads up. I used excel to remove everything except systID, xPos, yPos and export as tab-delimited text. I'll be careful when putting the data back in and reconverting to nova. I'm not done coding it yet anyways.

I haven't done any much coding in a while, so a few questions:

Firstly, what's an easy way of finding how many lines there are in a file so I know how big to make my arrays of system data?

Secondly, does this do what I expect it to do (parse the data file into allSys)?

struct systPoint {

		int ID;

		int x;

		int y;

} allSys(numsys);



while(originalData.good())

	{

		getline( originalData, fileLine );

		copyPosition = 0;

		searchPosition = 0;




		searchPosition = fileLine.find( "\t", 0);

		sysID = fileLine.substr(0, searchPosition);




		copyPosition = searchPosition;

		searchPosition = fileLine.find( "\t", copyPosition);

		xPos = fileLine.substr(copyPosition, searchPosition);

		

		copyPosition = searchPosition;

		searchPosition = fileLine.find( "\t", copyPosition);

		yPos = fileLine.substr(copyPosition, searchPosition);

		

		allSys(i).ID = atoi(sysID.data());

		allSys(i).x = atoi(xPos.data());

		allSys(i).y = atoi(yPos.data());

		

		i++;

	}

This post has been edited by LNSU : 21 January 2011 - 12:39 PM

Getting there:

I'm now using vectors instead of arrays for dynamics resizing purposes.

Current version here:

http://dl.dropbox.co...39/MoveSyst.cpp

The current issue I'm having is the while loop for processing the input file is only running once, not looping through the whole file.

Ideas?

Honestly, my idea is to do all the editing in Excel. If necessary make an extra column or two and put in some formulæ, then copy the new values into the proper locations. Copy and paste into a text editor for proper formatting when you’re done.