Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8258521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:34:00+00:00 2026-06-08T02:34:00+00:00

I work a lot with MongoDb Geospatial indexing, and now I am in the

  • 0

I work a lot with MongoDb Geospatial indexing, and now I am in the process of replacing the old NoRM framework with the official 10gen C Sharp driver. The problem I am having is that for the existing data that was handled by NoRM, coordinates were in the opposite order [y,x] and it seems like the official driver doesn’t like it.

So I for the existing data I have this structure:

{
   "Coordinates" [: 
   {
      "Longitude" : -85.68216, 
      "Latitude" : 38.221452          
   },
   //.. more coordinates
   ]
}

So my question is, how can I modify the order of all the elements within the array so it they look like:

{
   "Coordinates" [: 
   {
      "Latitude" : 38.221452,  
      "Longitude" : -85.68216               
   },
   //.. more coordinates
   ]
}

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:34:02+00:00Added an answer on June 8, 2026 at 2:34 am

    If you want to reverse the order, you’ll need to go through the entire collection and rewrite each document in the correct format. Here’s some JavaScript code to do that: feel free to season to taste.

    XDB = db.locations;
    var iter = XDB.find()
    
    do {
        var doc = iter.next();
        var newdoc = {};
        newdoc.Coordinates = [];
        for ( var k in doc.Coordinates ) {
            var newpair = { Latitude: doc.Coordinates[k].Latitude, 
                            Longitude: doc.Coordinates[k].Longitude } ;
            newdoc.Coordinates.push(newpair);
        }
        XDB.update({_id: doc._id}, newdoc );
    } while ( iter.hasNext() );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a lot of trouble getting XAMPP to work with MongoDB on
We work with a lot of real estate, and while rearchitecting how the data
I do a lot of work with temperatures in Textmate and I'd love to
I've been doing a lot of work with tuples and lists of tuples recently
I have an MVC app that does a lot of work with jQuery ajax
My work is running SQL Server 2008 and I spend a lot of time
Having a lot of trouble getting texture maps to work in openGL ES (iphone).
I used to work in JavaScript a lot and one thing that really bothered
The company I work for produces a lot of video and we want to
I work on a page where i want a lot of columns. The columns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.