This week, the Pennsylvania Supreme Court will consider whether the state’s harshly gerrymandered congressional map violates the state’s constitution.

The case is happening early enough in the year that the court could order a redrawn map ahead of the midterm elections. If that happens, Democrats will probably win at least one additional House seat this cycle, and they will be better positioned in several other seats.

The case is about state, not federal, law, so the result will stand regardless of how the United States Supreme Court rules on the biggest question of all: whether partisan gerrymandering violates the Constitution.

A Supreme Court ruling against partisan gerrymandering could usher in a half-dozen or more new congressional maps before the 2020 election, but probably not before this November’s midterm elections.

If the Supreme Court doesn't limit partisan gerrymandering, it could get a lot more extreme.

As unfavorable as the current map is for Democrats, Republicans could go even further in 2020 if they controlled the process again. This is unlikely because the Pennsylvania governor is now a Democrat, but Pennsylvania serves as a good illustration of how gerrymandering can play out.

We've redrawn the Pennsylvania congressional map in two ways. One is a neutral map, the kind that might be drawn by a nonpartisan committee. The other is an adventure in extreme gerrymandering that aims to maximize the number of Republican-held seats.

A Fairer Map

If Pennsylvania's Supreme Court rules that the state's congressional map must be redrawn, Democrats’ opportunities could improve a lot before the midterms.

It’s clear that the current one was drawn to the advantage of Republicans. Democrats won only five of the state’s 18 congressional districts in 2012, the year it took effect, even though they won the House statewide popular vote by 1.5 percentage points.

A nonpartisan map Current

map Extreme

gerrymander Median perimeter (approx.) 187 mi. 287 mi. 499 mi. Efficiency gap* +8 Rep. +14 Rep. +32 Rep. 2016 presidential election Districts won 7 11 6 12 3 15 Median vote Trump +9 Trump +9 Trump +13 2012 presidential election Districts won 9 9 5 13 3 15 Median vote Romney +2 Romney +5 Romney +6 *Based on 2016 presidential vote; figures are rounded

That’s partly because Democrats tend to “waste” votes in heavily Democratic urban areas, like Philadelphia and Pittsburgh. But the cartoon-moose-shaped Seventh District, running from Philadelphia city limits to Amish country, is routinely listed among the nation’s most gerrymandered. It's represented by the Republican Patrick Meehan, who faces a competitive re-election contest in a district that just barely voted for Hillary Clinton.

On this nonpartisan map, the Seventh would become a Democratic stronghold. The map here relies on standard nonpartisan redistricting criteria, like compactness and representing communities of interest.

Democrats would make more incremental gains in several other congressional districts where Republicans have taken more subtle steps to reinforce their position. The open 15th District, for example, would become a district where Mr. Trump won by just two points, not eight points. Democrats would probably be considered favorites to take the seat in this political environment.

This map represents a big improvement for Democrats over the Republican gerrymander. But it still might disappoint some Democrats. Donald J. Trump would have won 11 of these districts, even though he barely won the statewide popular vote. In fact, this map has an 8 percent efficiency gap in favor of the Republicans (in the 2016 presidential election). An 8 percent efficiency gap is a proposed threshold for whether a map should be considered an unconstitutional partisan gerrymander.

There’s a simple reason for this: Democrats waste a huge number of votes in Philadelphia and Pittsburgh. Mrs. Clinton won by 81 percent to 16 percent in those two cities combined, nearly enough for her to pull off the statewide victory. But those huge margins don’t yield any more congressional districts than a margin of, say, 65 to 35. If Mrs. Clinton had won Philadelphia and Pittsburgh by 30 points, she would have lost the state by 5.5 points. As a result, a nonpartisan map could end up yielding the results one would expect for a state that voted for Mr. Trump by a more comfortable margin.

An Extreme Gerrymander

As hard as it may be to believe, Republicans did show some restraint in 2010. They could have gone further. After eight years of additional political polarization along geographic lines, they can go further still.

Today, an extreme Republican gerrymander could plausibly reduce the Democrats to just three out of the 18 congressional districts, despite the fact they lost the state’s presidential vote by less than a percentage point in 2016.

Three ways you could draw Pennsylvania’s congressional districts: Current map

Our hypothetical Republicans pull it off by spoking the Philadelphia suburbs and borrowing more extensively from heavily Republican central Pennsylvania to shore up incumbents in southeastern Pennsylvania, two of which currently represent districts that voted for Mrs. Clinton. All of the vulnerable Republicans in southeastern Pennsylvania now find themselves in districts that voted comfortably for President Trump and Mitt Romney. The Democratic 17th District undergoes quite a makeover, and it adds a lot of reliably Republican territory. It’s probably enough to knock out the incumbent Democrat, Matt Cartwright.

The map makers then take a bold step, denying Democrats a second district by splitting up Pittsburgh. This is risky. It brings several southwest Pennsylvania districts to the edge of competitiveness, including the vacant 18th District — where a special election will be held in March. It also makes the open seats in the Ninth and 11th Districts much likelier to yield competitive contests. But our estimates indicate that the risk is probably worth it for Republicans, even in a wave election, in terms of maximizing the total number of expected Republican seats.

Our best guess is that Republicans would be favored to come away with 14 seats in the midterm elections if this map were adopted, up from the 13 they hold now and the 11 or 12 they’re expected to hold after this year’s midterms. In a more neutral or even Republican-leaning political environment, or over the course of a full decade, the Republican advantage is even greater.

(These estimates are based on election results since 2002 and include a measure of the effect of redistricting. We used the handy Dave’s Redistricting App and precinct-level election results from Ryne Rohla of Washington State University.)

This is probably a more aggressive gerrymander than the Republicans would consider. For one, it's a bad deal for many individual Republican incumbents, even if it's a pretty good deal for the party over all.

If there’s a wave election in November, incumbents in western Pennsylvania would find themselves in fairly competitive races. Keith Rothfus and Mike Kelly, in particular, would be in trouble. Their districts currently have a Cook Partisan Voter Index of R+11. With this redraw, Mr. Rothfus’s would drop to R+4 and Mr. Kelly’s to R+5. (The index measures a district’s partisanship based on its vote in recent presidential elections.)

But this might understate their vulnerability, since much of southwestern Pennsylvania has a strong Democratic tradition.

Virtually all Republican incumbents would become more vulnerable to a primary challenge because they would represent new constituents who wouldn’t be especially familiar with their new representatives.

A safer and more likely option would be to leave the Democrats a seat in Pittsburgh. Republicans could still easily improve their position over the current map by further spoking the districts of southeast Pennsylvania, and they would find it even easier to end the Democratic hold over the 17th District, where Mr. Cartwright won re-election by only eight points in 2016.

In general, this more cautious gerrymander would flip one Democratic seat and shore up the vulnerable Republicans, without newly endangering any Republican incumbents. The more aggressive gerrymander would cost the Democrats two seats, over the longer term.

This particular story is unlikely to play out in Pennsylvania because Democrats are favored to hold the governor's mansion through the next redistricting cycle. But something similar could occur elsewhere, across the country.